为什么我不能像这样cout
string
:
string text ;
text = WordList[i].substr(0,20) ;
cout << "String is : " << text << endl ;
当我这样做时,我收到以下错误:
Error 2 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) c:\users\mollasadra\documents\visual studio 2008\projects\barnamec\barnamec\barnamec.cpp 67 barnamec**
令人惊讶的是,即使这样也不起作用:
string text ;
text = "hello" ;
cout << "String is : " << text << endl ;
最佳答案
你需要包含
#include <string>
#include <iostream>
关于c++ - 为什么我不能找到一个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6320995/