Domanda

it's my first time to use auto in c++, and I work on linux, but I find it doesn't work at all. I want to know what happened. It's my code:

    //<STL container.cpp>
    //date: 2014.3.9 10:45
    #include<iostream>
    //#include<iterator>
    #include<vector>
    using namespace std;
    int main()
    {
        double a= 10.0;
        auto b=a;
        cout<<b;
        //for(auto it = mydata.begin();;it!=mydata.end();it++)
           // cout<<" "<<*it;
        cout<<endl;
        return 0;
    }

and codeblocks told me :

error:'b' does not name a type
error:'b' was not declared in this scope

I want to know whether codeblocks doesn't refer to auto or linux doesn't.

È stato utile?

Soluzione

Refer to this image on how to enable C++11 mode on CodeBlocks.

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top