auto
自动类型推断,用于从初始化表达式中推断出变量的数据类型,我在Qt5下面写的C++代码为什么出错?难道Qt5还不支持C++11?
#include <iostream>
using namespace std;
int main()
{
auto k=5;
return 0;
}
错误如下:
C:\Users\Administrator\Desktop\untitled\main.cpp:7:
错误:'k' does not name a type
auto k=5;
^C:\Users\Administrator\Desktop\untitled\main.cpp:8:
错误:'k' was not declared in this scope
cout<<k<<endl;
^
怪我咯2017-04-17 11:16:53
I don’t know which QT version of which platform the poster is using. Mine is ok. The environment is QT5.1.1 Mac OS Or the compiler is too old, please install the latest C++ compiler