title: Using maps inside class and accessing values via get() and set() functions from other class
body: <p>I am unable to use add values this map defined in header file as protected attribute from class member function.</p>
  
  <pre><code>class xyz{
  
  protected:
  
      map &lt; string, string &gt; *tagsMap;
  
  
  public:
      xyz();
  
      //set Tags
      void addTag(string _tagName, string _tagValue) const;
  }
  
  
  // In cpp class, 
  
  //set new Tags
  void xyz::addTag(string _tagName, string _tagValue) const {
  
      //map &lt; string, string &gt; tagsMap ;
      //gives error until I uncomment above line, but thats local map
  
      tagsMap.insert(pair&lt;string, string&gt;(_tagName, _tagValue));
  
      // first insert function version (single parameter):
      tagsMap .insert(pair&lt;string, string&gt;(_tagName, _tagValue));
  
      for (auto&amp; t : tagsMap )
          cout &lt;&lt; "addTag():" &lt;&lt; t.first &lt;&lt; "=" &lt;&lt; t.second &lt;&lt; endl;
  }
  </code></pre>