string定义数据,无法输入输出, 为什么
代码如下:
#include <iostream>
#include <string>
#include "stdafx.h "
using namespace std;
void main()
{
string word;
cin> > word;
cout < <word;
getchar();
return ;
}
编译后报错:
hello.cpp(13) : error C2679: 二进制“> > ” : 没有找到接受“”类型的右操作数的运算符(或没有可接受的转换)
hello.cpp(14) : error C2679: 二进制“ < <” : 没有找到接受“”类型的右操作数的运算符(或没有可接受的转换)
不知道到底是哪出的错我用的是.net 2003,望各位高手指点
[解决办法]
这样顺序包含头文件
#include "stdafx.h "
#include <iostream>
#include <string>