title: call member function in another class c++
body: <p>I have a class called Ball and a class Player.Inside my Ball class I create two pointers of type Player and I have two member methods so when I change the ball I can point to different players(current and previous). So I know that if I want to call the member methods of Ball inside a method in class Player they have to be static (and I also think that static methods operate with static variables too) but I seem to have huge difficulty and whatever I try I get a different error.</p>
  
  <p>Here follows <strong>Player.h</strong></p>
  
  <pre><code>#ifndef PLAYER_H
  #define PLAYER_H
  #include &lt;iostream&gt;
  #include "Player.h"
  
  using namespace std;
  
  class Player
  {
      public:
          //constructor of players
          Player(const string &amp;,int,int,int,int); //name,num,x,y,target_line
  
          //setters and getters
          //player's movements and functions
          void pass(Player*);
  
      private:
          string Name;
          int Num;
          int X;//0-5
          int Y;//0-9
          int Movement_line;
          int Target_line;
  
  };
  
  #endif // PLAYER_H
  </code></pre>
  
  <p>Here follows <strong>Player.cpp</strong> in which in method pass the problem I described occurs.</p>
  
  <pre><code>#include "Player.h"
  #include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include "Team.h"
  #include "Ball.h"
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  
  Player::Player(const string &amp;name,int num,int x,int y,int target_line)
  :   Name(name),
      Num(num),
      X(x),
      Y(y),
      Movement_line(y),
      Target_line(target_line)
  {
  }
  
  //setters and getters and other member functions
  
  void Player::pass(Player* next){
      changeCurrentToPrevious();
      changeNextToCurrent(next);
  }
  </code></pre>
  
  <p>Here follows <strong>Ball.h</strong> </p>
  
  <pre><code>#ifndef BALL_H
  #define BALL_H
  #include "Player.h"
  
  class Ball
  {
      public:
          Ball();
          Player* current;
          Player* previous;
  
          /*void setX_ball(int);
          int getX_ball() const;
          void setY_ball(int);
          int getY_ball() const;
          void assign();*/
          static void changeCurrentToPrevious();
          static void changeNextToCurrent(Player*);
  
  
      private:
          int X_ball;
          int Y_ball;
  };
  
  #endif // BALL_H
  </code></pre>
  
  <p>Here follows <strong>Ball.cpp</strong> </p>
  
  <pre><code>#include "Ball.h"
  #include "Team.h"
  #include "Player.h"
  
  Ball::Ball()
  :   X_ball(2),
      Y_ball(5)
  {
      current = NULL;
      previous = NULL;
  
  }
  
  static void Ball::changeCurrentToPrevious(){//when pass occurs
      previous = current ;
  }
  
  static void Ball::changeNextToCurrent(Player* next){
      current = next;
  }
  </code></pre>