title: How to iterate over a std::map full of strings in C++
body: <p>I have the following issue related to iterating over an associative array of strings defined using <code>std::map</code>.</p>
  
  <pre><code>-- snip --
  class something 
  {
  //...
     private:
        std::map&lt;std::string, std::string&gt; table;
  //...
  }
  </code></pre>
  
  <p>In the constructor I populate table with pairs of string keys associated to string data. Somewhere else I have a method <code>toString</code> that returns a string object that contains all the keys and associated data contained in the table object(as key=data format).</p>
  
  <pre><code>std::string something::toString() 
  {
          std::map&lt;std::string, std::string&gt;::iterator iter;
          std::string* strToReturn = new std::string("");
  
          for (iter = table.begin(); iter != table.end(); iter++) {
             strToReturn-&gt;append(iter-&gt;first());
             strToReturn-&gt;append('=');
             strToRetunr-&gt;append(iter-&gt;second());
             //....
          }
         //...
  }
  </code></pre>
  
  <p>When I'm trying to compile I get the following error:</p>
  
  <pre><code>error: "error: no match for call to ‘(std::basic_string&lt;char,
      std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;) ()’".
  </code></pre>
  
  <p>Could somebody explain to me what is missing, what I'm doing wrong? 
  I only found some discussion about a similar issue in the case of <code>hash_map</code> where the user has to define a hashing function to be able to use <code>hash_map</code> with <code>std::string</code> objects. Could be something similar also in my case?</p>