In C++, I want two classes to access each other
<p>I have two classes, <code>class A</code> and <code>class B</code>.</p>

<pre><code>A.h -&gt; A.cpp
B.h -&gt; B.cpp
</code></pre>

<p>And then, I set B as a member in class A. Then, class A can access class B by</p>

<pre><code>#include &lt;B.h&gt;   
</code></pre>

<p>But, how can I get the pointer of class A in class B and access the public member of class A?</p>

<p>I found some information about on the internet: a Cross-class. They said you can make it by setting the class B as a nested class in class A. </p>

<p>Do you have any other advice? </p>

<p>sorry.
myCode: as follow..</p>

<pre><code>class A:

#ifndef A
#define A

#include "B.h"

class A
{
public:
    A() {
        b = new B(this);
    }

private:
    B* b;
};

#endif


#ifndef B
#define B

#include"A.h"

class B
{
public:
    B(A* parent = 0) {
        this-&gt;parent = parent;
    }

private:
    A* parent;
};

#endif
</code></pre>
