开发者

C2146 Missing ; in Visual Studio 2010

I am getting the following the following errors when I try to compile in VS 2010. It is also complaining that string is undefined, which makes no sense, as I clearly included it. I understand what the errors mean, but they don't seem to make any sense:

1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(11): error C2146: syntax error : missing ';' before identifier 'profession' 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(16): error C2143: syntax error : missing ';' before '<' 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(16): error C2238: unexpected token(s) preceding ';' 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(23): error C2061: syntax error : identifier 'string' 1>c:\users\jon\documents\visual studio 2010\projects\project 2\project 2\userfactory.cpp(19): error C2061: syntax error : identifier 'map'

This is my code:

#include "objbase.h" //I found this recommendation while googling, but had the errors prior to adding this.
#include <string>
#include <map>
#include <utility>

class UserFac开发者_如何转开发tory {
public:
    class User {
        char gender;
        int id;
    string profession;// line 11
    int zip;
    friend class UserFactory;
};
private:
map<int,User*>* map;

public:
UserFactory() : map(new map<int,User*>()) { }

virtual ~UserFactory(void);

void process(string s) {
    //user id | age | gender | occupation | zip code

}
};

Any help would be appreciated before I rip my hair out!

Thanks!


string is part of the std namespace, so you must refer to it as std::string. The same applies to map.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜