Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto keyword not working in Dev c++ [duplicate]

This was a code I wrote to see how auto keyword works but it didn't got compiled in Dev C++ and gave the following warning: [Warning] C++11 auto only available with -std=c++11 or -std=gnu++11 How to overcome this glitch and do what the warning tells to do?

#include<iostream>
#include<string>
#include<vector>

using namespace std;
int main()
{
    std::vector<auto> v={2,-1,4,6,7};
    auto beg = v.begin();
    while (beg != v.end())
    {
        ++beg;
        cout<<beg;
    }
}
like image 630
Mukul Anand Avatar asked Mar 09 '23 11:03

Mukul Anand


1 Answers

You need to enable c++11 in the compiler using the switch instructions can be found here: How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?

like image 168
Treebeard Avatar answered Mar 20 '23 06:03

Treebeard