The auto keyword in C++ specifies that the type of the variable that is being declared will be automatically deducted from its initializer. In case of functions, if their return type is auto then that will be evaluated by return type expression at runtime.
1 2 3 4 5
The same code produces error in Dev-C++:
If you want to traverse a vector using an auto keyword (as shown in the above code), then it will show error as:
Why does this error occur in Dev-C++:
The auto keyword introduces in C++ 11, and it is allowed to the user to leave the type deduction to the compiler itself. But while running a program in Dev-C++ then it will be showing error, because in Dev-C++ inbuilt C++98 compiler so that’s by that error occurs.
How to fix this error:
Below are the steps to solve the error:
- Open Dev C++ go to ->tools.
- Click on ->compiler options(1st option).
- A new window will open and in that window click on -> settings:
- Go to -> code generation:
- In language standard column(std) choose ->ISO C++11:
- Click on OK and After that the code will execute and will give no error.
Now the code works fine and prints the expected output.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- std::cerr | Error Stream Object in C++ with Examples
- NULL undeclared error in C/C++ and how to resolve it
- Custom Jumble Word Game
- Comparator Class in C++ with Examples
- 5 Tips to Make a Career as a Linux Kernel Developer
- How to Integrate Emojis in an Android App?
- Competitive Coding Setup for C++ and Python in VS Code using Python Script
- Program to find largest element in an array using Dynamic Memory Allocation
- How to Install CMake for Windows in Python?
- How to configure an OAuth App from GitHub?
- Life cycle of Objects in C++ with Example
- How to Create Your Own Shortcut in Android Studio?
- How to Make Changes to The Application Deployed on Heroku ?
- How to enable customers to know if your wordpress website delivers at their pincode or not?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.