How can a class A, that is a member of class B, share private members of class B?
<p>I have the following code:</p>

<p>Master.h</p>

<pre><code>#ifndef MASTER_H
#define MASTER_H

class Master
{
   friend class Friend;

   public:
      Master(void);
      ~Master(void);
      void CallFriendFunction(int largeData);

   private:
      int    largeData;

      //Want this class to share largeData;
      Friend testFriend;
};
#endif // MASTER_H
</code></pre>

<p>Master.cpp</p>

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

Master::Master(void)
{
   //Inentionally left blank
}

Master::~Master(void)
{
   //Intentionally left blank
}

void Master::CallFriendFunction(int largeData)
{
   this-&gt;largeData = largeData;
   this-&gt;testFriend.Test(this);
}
</code></pre>

<p>Friend.h</p>

<pre><code>#ifndef FRIEND_H
#define FRIEND_H

#include "Master.h"

class Friend
{
   public:
      Friend(void);
      ~Friend(void);

      void Test(Master* masterPtr);
};

#endif // FRIEND_H
</code></pre>

<p>Friend.cpp</p>

<pre><code>#include "Friend.h"
#include &lt;iostream&gt;

Friend::Friend(void)
{
   //Intentionally left blank
}

Friend::~Friend(void)
{
   //Intentionally left blank
}

void Friend::Test(Master* masterPtr)
{
   std::cout &lt;&lt; masterPtr-&gt;largeData &lt;&lt; std::endl;
}
</code></pre>

<p>I want class Friend to be able to share Master's private members. However, I can't get this code to compile. I've tried Forward Declaration, and #includes, but I start getting into circular dependencies. When Friend class is not a member of Master class, the code compiles?</p>

<p>Is it possible for Friend class be a member of Master and be friends? 
How else can Friend class have access to Masters private members?</p>
