In Eclipse is the "auto" Keyword work in the same way it would in C++11? I get the following error:
#include <iostream>
using namespace std;
int main()
{
auto flag = true;
auto Number = 2500000000000;
cout << "flag = " << flag;
cout << " , sizeof(flag) = " << sizeof(flag) << endl;
cout << "Number = " << Number;
cout << " , sizeof(Number) = " << sizeof(Number) << endl;
return 0;
}
Error: "ISO C++ forbids declaration of 'flag' with no type
Error: "ISO C++ forbids declaration of 'Number' with no type
The auto keyword 's automatic identification of data type is a recent feature incorporated in C++11, though it was present in previous versions of C. I believe the C++ library in your eclipse doesn't have the feature or maybe you don't have the latest version. I had similar issue on Code Blocks, even though it showed C++11. But the same C++11 had the feature functioning on Ubuntu's terminal Try updating it yourself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.