STL containers fails to add a structure defined inside a function
<p>I have enanoutered a problem with a code similar to this </p>

<pre><code>void aFuncion()
{
    struct entry
    {
        std::string field1;
        int         field2;
        int         field3;

        entry(const entry&amp; ent)
        { 
            // copy constructor code 
        }

        entry()
        { 
            // default constructor code 
        }

        entry(std::string s, int a, int b)
        { 
            field1 = s;
            field2 = a;
            field3 = b;
        }

    }; //end of structure definition 

    std::vector&lt;entry&gt; vec;
    entry en("a string", 1, 2);

    vec.push_back(en);  // vec has garbage in index 0
}
</code></pre>

<p>after pushing the entry into the vector the debuggers shows only garbage in the vector first entry.   </p>

<p>the problem resolved once we took the structure definition  out of the function.<br>
<strong>why did the problem occur how did getting the definition into  out of the function resolved it ?</strong>  </p>

<p>(we are working with VS 2008  on XP 32 bit )</p>
