首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

windows程序设计,这样错哪了

2012-04-02 
windows程序设计,这样哪里错了?刚学windows程序设计,工具vc++6.0,想定义一个string 类,已引入#include 《st

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.
[解决办法]

探讨
编译通过了,运行什么结果也没有,这个为什么啊??
加了 getchar()也没有用。

[解决办法]
哈哈,楼上有道理

热点排行