initialization of a reference in a dynamically allocated structure
<p>Anyone knows how to initialize a reference in a dynamically allocated structure?
or why this doesnt work?</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

class A
{

};

struct S
{
    A&amp; a;
};

int main()
{
    A a;

    S* s=new S;
    s-&gt;a=a;

    printf("a addr:%p\n", &amp;a);
    printf("s-&gt;a addr:%p\n", &amp;(s-&gt;a));
delete s;
    return 0;
}
</code></pre>

<p>output:</p>

<pre><code>a addr:0x7fff95b65aaf
s-&gt;a addr:(nil)
</code></pre>
