Visual Studio2008 环境下写了如下两行代码,
string data;
cin >> data;
结果编译时告知 :
error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
云云
表面上看是 cin >> 不支持 string,
后来找到问题了
是没有 #include <string> ,
可是我不明白了,为什么没有#include <string> 不在 string data 声明的时候报错,而在负值的时候报错!
不管怎么说,问题是没有#include <string>。