C++ STL map with custom comparator storing null pointers
<p>I'm trying to write a copy constructor for an object managing a STL map containing pointers, where the key is a string. However, when I attempt to insert new values in the map, the pointers are set to NULL:</p>

<pre><code>// ...
for(std::map&lt;std::string, data_base*, order&gt;::const_iterator it = other.elements.begin();
it != other.elements.end(); ++it){
    data_base *t = it-&gt;second-&gt;clone();
    std::cout &lt;&lt; "CLONE: " &lt;&lt; std::hex &lt;&lt; t &lt;&lt; std::endl;
    elements[it-&gt;first] = t;
    std::cout &lt;&lt; "INSERTED: " &lt;&lt; std::hex &lt;&lt; elements[it-&gt;first] &lt;&lt; std::endl;
}
// ...
</code></pre>

<p><code>other</code> is the object being copied and <code>elements</code> the map. The <code>clone()</code> method returns a pointer to a new object (via <code>new</code>).</p>

<p>Running the code above I get something like:</p>

<pre><code>CLONE: 0xcfbbc0
INSERTED: 0
</code></pre>

<p>I'm not a very experienced programmer and this issue is probably simple to fix, but I didnt find any solution to it searching around.</p>

<p>Thanks a lot for your time.</p>
