當我嘗試在VS 2010中進行編譯時,出現以下錯誤。它也在抱怨字符串未定義,這沒有任何意義,因爲我明確包含它。我明白了什麼錯誤的意思,但他們似乎沒有任何意義:C2146缺失;在Visual Studio 2010中
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'
這是我的代碼:
#include "objbase.h" //I found this recommendation while googling, but had the errors prior to adding this.
#include <string>
#include <map>
#include <utility>
class UserFactory {
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
}
};
任何幫助,將不勝感激之前,我撕裂我的頭髮!
謝謝!
應該不是std :: string職業? – Bart 2010-11-14 19:25:41