When i try to compile the following code:
#include <string.h>
using namespace std;
typedef std::basic_string<char> foostring;
foostring foo = "foo";
I get the following error:
stringtest.cpp:5: error: expected initializer before ‘<’ token
stringtest.cpp:6: error: ‘foostring’ does not name a type
My compiler is: g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
What am i doing wrong? i intend to use this with windows TCHAR for unicode support once i figure out how to use it.
The header is <string>
, not <string.h>
.
None of the standard library headers end with an extension. (You're including the C header string.h
, which should be included in C++ via <cstring>
, had that been what you actually wanted.)