Access member of class from a constructor of another class
<p>My code looks something like this:</p>

<p>main.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include "A.h"
#include "B.h"
using namespace std;

int main(){

int d,f;
A c();
d = c.GetStuff();

B *d = new C();
f = d-&gt;Get();

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

<p>A.h</p>

<pre><code>#ifndef A_H
#define A_H
class A
{
int a;

public A();

int GetStuff() {return(a) ;}

};

#endif
</code></pre>

<p>A.cpp</p>

<pre><code>#include "A.h"

A::A()
{
 a = 42;//just some value for sake of illustration
}
</code></pre>

<p>B.h</p>

<pre><code>#ifndef B_H
#define B_H

Class B 
{
public:
virtual int Get(void) =0;

};

class C: public B {
public:
C();

int Get(void) {return(a);}
};
#endif
</code></pre>

<p>B.cpp</p>

<pre><code>#include "B.h"

C::C() {
a // want to access this int a that occurs in A.cpp
}
</code></pre>

<p>My question is, what is the best way to gain access to "a" in B.cpp?
I tried using class "friend", but I am not getting results.</p>

<p>Any suggestions?
Thanks!</p>
