title: How to access the friend class method?
body: <p>I am new to C++. Please have a look at the following code</p>
  
  <p><strong>Position.h</strong></p>
  
  <pre><code>#pragma once
  class Position
  {
  public:
      Position(int x, int y, int z);
      Position();
      ~Position();
  
      void display();
  
  private:
      int x;
      int y;
      int z;
  };
  </code></pre>
  
  <p><strong>Position.cpp</strong></p>
  
  <pre><code>#include "Position.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  Position::Position(int x, int y, int z)
  {
      this-&gt;x = x;
      this-&gt;y = y;
      this-&gt;z = z;
  }
  
  Position::Position(){}
  
  
  Position::~Position(void)
  {
  }
  </code></pre>
  
  <p><strong>GameComponent.h</strong></p>
  
  <pre><code>#pragma once
  #include&lt;time.h&gt;
  
  class GameComponent
  {
  public:
      GameComponent(int);
      GameComponent();
      ~GameComponent(void);
  
      virtual void update(const tm*);
      friend class Position;
  
  private:
      int id;
  };
  </code></pre>
  
  <p><strong>GameComponent.cpp</strong></p>
  
  <pre><code>#include "GameComponent.h"
  #include &lt;iostream&gt;
  #include &lt;time.h&gt;
  #include "DrawableGameComponent.h"
  
  using namespace std;
  
  GameComponent::GameComponent(int v):id(v)
  {
  
  }
  
  GameComponent::GameComponent(){}
  
  
  GameComponent::~GameComponent(void)
  {
  
  }
  
  void GameComponent::update(const tm* time)
  {
      cout &lt;&lt; "ID : " &lt;&lt; id &lt;&lt; endl;
      cout &lt;&lt; "Update: " &lt;&lt; time-&gt;tm_hour &lt;&lt; ":" &lt;&lt; time-&gt;tm_min &lt;&lt; ":" &lt;&lt; time-&gt;tm_sec &lt;&lt; endl;
  
      //Position::displayPositions();
  }
  
  void Position::display()
  {
      cout &lt;&lt; "X" &lt;&lt; x &lt;&lt; "Y" &lt;&lt; y &lt;&lt; "Z" &lt;&lt; z &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I need to access the method <code>display()</code> which is belongs to friend class <code>Position</code> of class <code>GameComponent</code> inside GameComponent's <code>update(const tm* time)</code> method. Actually what I am trying to do is to access the private data members of class <code>Position</code>. How can I do this? Please help</p>