Don't understand how variable I is getting assigned a value in a struct
<p>I have the following code:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

struct S {
    S(int i): I(i) { }
    int &amp; v () { return I; }
    private :
    int I;
};

S s1 (1);
int main() {

    cout &lt;&lt; s1.v() &lt;&lt; "\n";

    return 0;
}
</code></pre>

<p>And I get the output:</p>

<pre><code>1
</code></pre>

<p>I am confused as  to how it is working. For example with <code>s1</code> it is calling the constructor <code>S(int i)</code> but how is it sub-classing <code>I</code> and calling its constructor when there is no <code>I</code> class and how is the private variable <code>I</code> getting assigned a number when there has been nothing assigned to it? Also, if <code>v()</code> returns <code>int&amp;</code> (a reference therefore, I would think it would print out a memory location but it gives 1 consistently).</p>

<p>Sorry if this sounds stupid can't figure it out.</p>
