请高人指点如何编译通过这个 C++ 程序

程序员长弓 2007-04-17 09:30:21
怎么解决下面程序在VC 6.0中的编译错误,请高人指点迷津!!!!!!!

#include<iostream.h>
#include<string>
#include<vector>

using namespace std;

void mian()
{
string word;
vector<string> text;
while(cin>>word)
text.push_back(word);

cout<<"Words read are: \n";
for(vector<string>::iterator it=text.begin();
it!=text.end();++it)
cout<<*it<<' ';
cout<<endl;
}



编译错误如下所示:

D:\test\test.cpp(11) : 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)
D:\test\test.cpp(11) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

test.obj - 2 error(s), 0 warning(s)
...全文
262 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
guanwl 2007-04-18
  • 打赏
  • 举报
回复
#include<iostream.h>
改成
#include <iostream>


<iostream>才是stl中的东东, 也就是using namespace std;所要用的.
<iostream.h>是C++以前的io库, 不支持 <string> 中的string.

freshui 2007-04-17
  • 打赏
  • 举报
回复
VC6.0是原始社会的编译器
连标准C++都不能支持
呵呵
还是换了吧
xuzheng318 2007-04-17
  • 打赏
  • 举报
回复
改成标准
merlinfang 2007-04-17
  • 打赏
  • 举报
回复
#include<iostream.h>改为#include<iostream>
snprintf 2007-04-17
  • 打赏
  • 举报
回复
#include<iostream.h>
改成
#include <iostream>
hellox 2007-04-17
  • 打赏
  • 举报
回复
没有别的错误...
有的话是6.0的毛病...呵呵..
hellox 2007-04-17
  • 打赏
  • 举报
回复
void mian()
=========
void main()

65,212

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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