我有这个简单的代码:
#include <string>
#include <iostream>
using namespace std;
int main() {
string s1 = "rohit";
auto len = s1.size();
cout << len;
}
当我在 Ubuntu 12.04 上编译此代码时,它显示以下错误:
test.cc: In function ‘int main()’:
test.cc:8:10: error: ‘len’ does not name a type
auto len = s1.size();
^
test.cc:10:13: error: ‘len’ was not declared in this scope
cout << len;
^
我有g++ 4.8.1。auto
g++ 4.8.1 中关键字的使用是否有一些变化?