windows程序设计,这样哪里错了?
刚学windows程序设计,工具vc++6.0,想定义一个string 类,
已引入#include 《string》,
code:
char buff[100]={'\0'};
char buff2[10]={'\0'};
string temp=NULL;
char * end1=NULL,end2=NULL;
编译错误:
F:\mfc\math\math.cpp(140) : error C2146: syntax error : missing ';' before identifier 'temp'
F:\mfc\math\math.cpp(140) : error C2501: 'string' : missing storage-class or type specifiers
F:\mfc\math\math.cpp(140) : fatal error C1004: unexpected end of file found
[解决办法]
string 需要加 namespace,即 std
比如 std::string temp;
或者在开始处加上 using std::string 或 using namespace std;
[解决办法]
temp.resize(0);
OK.
[解决办法]
[解决办法]
哈哈,楼上有道理