-3

I was going through a program in C++. I am a beginner, so I was bit confused what's the meaning of this.

Problem was this:

https://www.codechef.com/problems/H1

I saw someone's solution and am confused what the meaning of map<string, int> m= {}; is.

https://www.codechef.com/viewsolution/20124020

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696

1 Answers1

4

std::map<Key, Value> is an associative container that maps keys to values. See std::map for full details.

map<string, int> m = {}; invokes the default constructor of map<string, int>. In fact, = {} part is unnecessary map<string, int> m; does the same thing in a less verbose way.

Also, if both the default constructor and the initializer list constructors are available, = {} calls the default constructor.

Maxim Egorushkin
  • 125,859
  • 15
  • 164
  • 254