Error C2061: syntax error

Started by
4 comments, last by Habba 18 years, 8 months ago
I'm trying to use string-class with my program, and I've included string.h (#include <string.h>), but I still can't use string-class. I get this error while compiling: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/c2061.asp
Advertisement
The string class lives in the <string> header not the <string.h> header.
I changed it to:

#include <string>

but it didn't help, I got still the same error.
Maybe you could post the code region, where the error occurs...
The other possible problem is that the string class lives in the std namespace, so you should either prefix the string identifier with std:: as in std::string or use a using statement or directive to bring string in from the std namespace. ex: using namespace std; or using std::string;

If that doesn't work for you, you'll probably need to post the code you are trying to compile.
It was a namespace issue alright, but first I tried to add "using namespace std", but it didn't work, so I ended to use std::string istead of just string while declaring the class. I guess it's okay then. Thank you all.

This topic is closed to new replies.

Advertisement