求教,不知道大家碰到过吗?
#include <string>
#include <iostream>
class x {
public:
string a ;
string b ;
};
int main(){
x x1;
x1.a = "sdfsdfsd";
cout<<x1.a;
}
编译时出错:
error C2146: syntax error : missing ';' before identifier 'a'
error C2501: 'string' : missing storage-class or type specifiers
error C2501: 'a' : missing storage-class or type specifiers
error C2146: syntax error : missing ';' before identifier 'b'
error C2501: 'string' : missing storage-class or type specifiers
error C2501: 'b' : missing storage-class or type specifiers
不知道什么原因。
若用int代替string就没有此种问题。