Does a c++ struct have a default constructor?
<p>I wrote the following code snippet:</p>

<pre><code>void foo()
{
    struct _bar_ 
    {
        int a;
    } bar; 

    cout &lt;&lt; "Value of a is " &lt;&lt; bar.a;
}
</code></pre>

<p>and compiled it with g++ 4.2.1 (Mac). The output is "Value of a is 0".</p>

<p>Is it true to say that data members of a struct in c++ are always initialized by default (compared to c)? Or is the observed result just coincidence?</p>

<p>I can imagine that structs in c++ have a default constructor (since a struct and a class is almost the same in c++), which would explain why the data member a of bar is initialized to zero.  </p>
