自学string 发现了问题但是不知道错在哪里了
#include
#include
#include
#include
using std:: string;
using namespace std;
int main()
{
string str("some string");
for( auto c:str)
cout << c << endl;
return 0;
}
你的编译器版本是多少? auto是c++11的新特性, 需要vs2013以上的版本
你是错哪了? 你要说出来啊! 是编译不通过吗? 你是用C++11的语法写的,编译器要开C++11
string类可以直接用 string str("balala"); cout<<str ; 不需要循环输出的
直接cout<<str;就行了。