请教cin的问题
#include <iostream>
using namespace std;
void main()
{
string word;
cin> > word;
}
为什么编译错误:error C2679: binary '> > ' : no operator found which takes a right-hand operand of type 'std::string ' (or there is no acceptable conversion)
VC2003.
[解决办法]
#include <string>
[解决办法]
楼上正解.要用string类型必须包含string头文件
[解决办法]
是的 ,要使用 string 类型 ,一定要 包含 #include <string>
[解决办法]
正解,要使用string类型及它的成员函数,就必须包含 <string> 头文件.
[解决办法]
不错必须这么用才行啊,我曾经试过不加using namse space 可是却不行啊
[解决办法]
不加using namespace std;也可以
不过在使用stl库所定义的东西的时候就要加上相应的名字空间
比如使用string的时候要用std::string,使用标准输出流的话要用
std::cout < < "hello world! " < < std::endl;