Error while compiling simple Map program.

I am getting a warning and an error.

Warning- D:\Map\main.cpp|7|warning: extended initializer lists only available with -std=c++11 or -std=gnu++11|

Error-D:\Map\main.cpp|7|error: in C++98 'm' must be initialized by constructor, not by '{...}'|

1
2
3
4
5
6
7
8
9
10
11
12
  #include <iostream>
#include<map>
using namespace std;

int main()
{
    map<int,string> m{{1,"Kumar"},{2,"Shree"},{4,"sony"}};

    cout<<m.at(1)<<endl;
    return 0;
}
Well....why not add all of those later..
You need to enable C++11 in your compiler.
Topic archived. No new replies allowed.