1

I am a beginner in c++. I am using visual studio code for Mac. My problem is that whenever I use "auto" for variable declaration visual studio code gives me a warning like this:

warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]

I tried changing the C_Cpp Standard> Default: Cpp Standard to c++11 in the user settings, but it still gives me a warning.

Here is my code if it's necessary

#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;
}
mch
  • 9,424
  • 2
  • 28
  • 42
Aiman
  • 11
  • 1
  • I fixed your code formatting. Your `do {` ends in a `}` without `while` and your `} while` is the end of `if(selection....`. – mch Nov 15 '21 at 09:31

0 Answers0