这是我第一次在c++中使用auto,我在linux上工作,但我发现它根本不起作用。我想知道发生了什么事。这是我的密码:

    //<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;
    }

代码块告诉我:
error:'b' does not name a type
error:'b' was not declared in this scope

我想知道代码块是否不引用auto或linux。

最佳答案

请参阅关于如何在CODBULD上启用C++ 11模式的图像。

关于c++ - 为什么我不能在Linux的代码块中使用“自动”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22277948/

10-10 22:17
查看更多