0

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

Daniel Frey
  • 55,810
  • 13
  • 122
  • 180
bmittin
  • 7
  • 2
  • possible duplicate of [Eclipse CDT C++11/C++0x support](http://stackoverflow.com/questions/9131763/eclipse-cdt-c11-c0x-support) – Daniel Frey Oct 15 '13 at 06:08

1 Answers1

0

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.

adimoh
  • 658
  • 2
  • 8
  • 20