问题描述
- 自学string 发现了问题但是不知道错在哪里了
-
自学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;就行了。
时间: 2024-09-19 08:57:31