为什么是error C2065: 'string' : undeclared identifier

gonghai78 2003-07-22 03:48:13
C++ PRIMER电子版上的源代码
在win2000+vc 6(英文班)下的编译错误,请教是什么原因?

#include <iostream.h>
#include <string.h>
int main()
{

string* word;
while ( cin>>word )

cout<<"word read is: "<<word;

cout<<"ok: no more words to read: bye!\n";
return 0;
}
...全文
2221 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bfsky 2004-03-02
  • 打赏
  • 举报
回复
wowowowo(1) 你的方法我试过了,还是有错啊。我的测试环境和楼主的一样,也是在win2000+vc 6(英文版)下的编译错误,请教是什么原因?


--------------------Configuration: 3_4 - Win32 Debug--------------------
Compiling...
3_4.cpp
e:\tst\3_4\3_4.cpp(9) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *' (or there is no acceptable conversion)
e:\tst\3_4\3_4.cpp(9) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

3_4.obj - 2 error(s), 0 warning(s)
点燃你的火花 2003-07-22
  • 打赏
  • 举报
回复
同意楼上!
wowowowo 2003-07-22
  • 打赏
  • 举报
回复
#include <iostream.h>
#include <string.h>
改为
#include <iostream>
#include <string>
using namespace std;
bm1408 2003-07-22
  • 打赏
  • 举报
回复
打开命名空间!using namespace std;

fierygnu 2003-07-22
  • 打赏
  • 举报
回复
using namespace std;

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧