gpt4 book ai didi

c++ - 为什么我不能在 linux 的代码块中使用 "auto"

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:52:31 25 4
gpt4 key购买 nike

这是我第一次在 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

我想知道 codeblocks 是不是指 auto 还是 linux 不是。

最佳答案

请参阅此图片了解如何在 CodeBlocks 上启用 C++11 模式。

enter image description here

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com