错误:未命名类型(使用自动) [英] Error: does not name a type (using auto)
问题描述
我正在使用第5版c ++入门自动学习。他们给了我一些例子,例如:
I am studying auto with the c++ primer 5th edition. They gave me examples such as:
auto item = val1 + val2;
据我了解,auto会自动告诉您所用表达式的类型。所以我做了我自己的事:
From what I understand auto tells you what type forms from the expression you make. So I did my own:
int test1 = 69, test2 = 72;
auto test3 = test1 + test2;
但是我得到了错误:'test3'没有命名类型
but i got the error: " 'test3' does not name a type"
这是什么意思?我虽然test3将成为与test1,test2相同的类型,它是int。
What does this mean? I though test3 will become the same type as test1,test2 which is int.
推荐答案
我在没有<$ c $的情况下运行了示例c>-std = c ++ 11 ,它会失败,并显示相同的错误消息。
I run the example without --std=c++11
, it fails with the same error message.
Try to configure codeblocks again like this suggests.
或者您可以像 g ++ --std = c ++ 11 code.cc
这样手动运行代码。
Or you can run the code by hand like g++ --std=c++11 code.cc
.
要查看是否启用了C ++ 11,可以键入更多的C ++ 11代码,就像声明嵌套向量 vector< vector< vector< int>> vv;
以查看它是否很好地处理>>
。
To see if C++11 is enabled, you can type more C++11 code, like just declaring nested vector vector<vector<int>> vv;
to see if it deals >>
well.
- How can I add C++11 support to Code::Blocks compiler?
这篇关于错误:未命名类型(使用自动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!