C++ string问题
- C/C++ code
#include "iostream"#include "cstring"using namespace std;int main(){ string str = "switch"; cout <<str <<endl; return 0;}
编译报错: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)
难道VC6.0中cout函数不支持string类型的输出
[解决办法]
包含的头文件错了:
- C/C++ code
#include <string> //std::string
[解决办法]
[解决办法]