local classes c-ism
<p>Only first pair of values output on running this program seem correct, the others don't. What is going on?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;

class a
{
    public:
        class b
        {
            public:
                a* parent;
                void test()
                {
                    std::cout&lt;&lt;parent-&gt;value&lt;&lt;std::endl;
                }
        } b1;
        unsigned long value;
        a()
        {
            b1.parent = this;
            value = 2;
        }
        void go()
        {
            value++;
            b1.test();
        }
};

int main()
{
    {
        a a1;
        a1.go();
        std::cout&lt;&lt;a1.value&lt;&lt;std::endl;
    }
    std::cout&lt;&lt;std::endl;
    {
        a a1; a1 = a();
        a1.go();
        std::cout&lt;&lt;a1.value&lt;&lt;std::endl;
    }
    std::cout&lt;&lt;std::endl;
    {
        std::vector&lt;a&gt; a1; a1.push_back(a());
        a1.at(0).go();
        std::cout&lt;&lt;a1.at(0).value&lt;&lt;std::endl;
    }
    return 0;
}
</code></pre>
