title: How to construct object from initializer list of pairs?
body: <p>In this code I am trying to initialize class object using initializer_list of pair(int,pair(string,string)), but I am getting error in initializing class member  map2 of type map(int,pair(string,string)).</p>
  
  <p>Here is my code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;initializer_list&gt;
  #include &lt;map&gt;
  using namespace std;
  
  class contact{
  private:
  
          map &lt;int,pair&lt;string,string&gt;&gt; map2;
  
  public:
  
      contact(initializer_list&lt;pair&lt;int,pair&lt;string,string&gt;&gt;&gt; m):map2(m){}
      void display(){
          for (const auto&amp; it:map2){
              cout&lt;&lt;it.first;
          }
      }
  };
  
  int main() {
      contact obj{
          make_pair(4,make_pair("parul","agrawal")),
          make_pair(5,make_pair("keshav","agrawal")),
      };
  
      obj.display();
      return 0;
  }
  </code></pre>