c++ - 在 Mac 的 Visual Studio 代码中删除“自动”类型说明符和基于范围的循环 C++ 扩展警告
问题描述
我是 C++ 的初学者。我正在为 Mac 使用 Visual Studio 代码。我的问题是,每当我使用“auto”进行变量声明时,Visual Studio 代码都会给我一个警告,如下所示:
警告:'auto' 类型说明符是 C++11 扩展 [-Wc++11-extensions]
我尝试在用户设置中将 C_Cpp Standard> Default: Cpp Standard 更改为 c++11,但它仍然给我一个警告。
如果有必要,这是我的代码
#include<iostream>
using namespace std;
int main(){
vector<int> numbers;
char selection;
do
{
cout<<"\nP - Print numbers"<<endl;
cout<<"A - Add a number"<<endl;
cout<<"M - Display mean of the numbers"<<endl;
cout<<"S - Display the smallest number"<<endl;
cout<<"L - Display the largest number"<<endl;
cout<<"Q - Quit"<<endl;
cout<<"Enter your choice:"<<endl;
cin>>selection;
}
cout<<endl;
if(selection == 'p' || selection == 'P'){
if(numbers.size() == 0){
cout<<"[] - the list is empty"<<endl;
}
else{
cout<<"[ ";
for(auto num: numbers){
cout<< num << " ";
cout<< "]" <<endl;
}
}
}while (selection != 'q' || selection != 'Q');
return 0;
}
解决方案
推荐阅读
- reactjs - 使用带有对象属性的条件渲染时出现语法错误
- .net - 纯 Windows 环境中的 Orchestrator
- java - 使用 Java 8 可选 - 转换逻辑
- python - 在 Keras v2 中计算精度、召回率和 F1,我做对了吗?
- c - C定义/全局变量,它依赖于其他东西
- ios - 如何在按钮中使用两行显示来自两个 NSString 变量的两行字符串值
- highcharts - 如何在 highchart 的标签中使用 line-height 属性
- java - 按钮最有效的点击是什么?
- r - macOS 上 R 3.5 中的 devEMF 包无法构建
- symmetricds - SymmetricDS:路由器到所有或特定节点