dimanche 10 septembre 2017

How to initialize a nested map in constructor initialization list in c++

class test{
   public:
      test();
   ...
   private:
      map<int, string> map1;
      map<int, map<int, string>> map2; //two dimensional map
   ...
};

test::test():map1()
{}

I am trying to initialise map using initialization list. For simple(single) map, we can initialize to call map constructor(map1()) in initialization list. But how can I initialize to nested map(map2) in constructor initialization list.

Thanks in advance for your help.

Aucun commentaire:

Enregistrer un commentaire