在下面的示例代码中
std::string result = exec( "dir" ) ;
cout<<result;
出现以下错误
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string
我怀疑有一种特殊的方法可以打印出 std::string
。
请帮我调试一下。
此外,我还包含了 iostream.h、fstream.h 和 stream 头文件。
最佳答案
我怀疑您需要使用 std::
来限定 cout
std::cout << result;
或将 using namespace::std
添加到您的 cpp 文件的顶部。
关于c++ - 打印出 std::string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10668128/