-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
  • 555,201
  • 31
  • 458
  • 770

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
  • 131,725
  • 17
  • 180
  • 271