#include <string>
#include <iostream>
using namespace std;
int main()
{
string test_string = "abc";
for (auto c : test_string)
cout << c << endl;
}
######报错信息
问题应该是编译选项问题,如果你用的DEV的情况下,这样操作:
auto
和range-for
都是C++11引入的新语法。你先确定你的编译器支持C++11标准,并且你打开了C++11的编译选项。