title: Order of Class Definitions in C++
body: <p>I've got a bit of a problem here.  I'm trying to define several classes, of which some are Players and some are Pawns belonging to the players.  Coming from Python, I'm used to being able to conveniently access a Pawn's owning Player through the Pawn, as well as accessing a Player's Pawns through the Player.  Correct me if I'm wrong, but this seems impossible in C++.</p>
  
  <p>I currently define Player first, and one of its data members <code>m_Pawns</code> is supposed to be a <code>vector&lt;Pawn&gt;</code>.  I declare the data member, but I don't assign it any value.  I also define a member function that is meant to assign a vector of pawns to <code>m_Pawns</code>, but I don't call it anywhere near the constructor.  Since I'm not actually calling the constructor for <code>Pawn</code> in the constructor for <code>Player</code>, it seems I should be fine.</p>
  
  <p>Here's my <code>Player</code> class.  The <code>Board</code> class is defined beforehand, whereas the <code>Pawn</code> class is defined afterwards (the <code>Pawn</code> class contains pointers to an owner of the <code>Player</code> class, so switching it around doesn't really help).</p>
  
  <pre><code>class Player
  {
  public:
      Player(sf::Color color, const string&amp; name);
      sf::Color GetColor();
      string GetName();
      void CreatePawns(Board&amp; board, int which);
  protected:
      vector&lt;Pawn&gt; m_Pawns;
      sf::Color m_Color;
      string m_Name;
  };
  
  Player::Player(sf::Color color, const string&amp; name):
      m_Color(color),
      m_Name(name)
  {}
  
  sf::Color Player::GetColor()
  {
      return m_Color;
  }
  
  string Player::GetName()
  {
      return m_Name;
  }
  
  void Player::CreatePawns(Board&amp; board, int which)
  {
      switch(which)
      {
      case 1:
          for(int i = 0; i &lt; 4; ++i)
          {
              m_Pawns.push_back(Pawn((*board).Cluster1[i], this*, m_Color));
          }
          break;
      case 2:
          for(int i = 0; i &lt; 4; ++i)
          {
              m_Pawns.push_back(Pawn((*board).Cluster2[i], this*, m_Color));
          }
          break;
      case 3:
          for(int i = 0; i &lt; 4; ++i)
          {
              m_Pawns.push_back(Pawn((*board).Cluster3[i], this*, m_Color));
          }
          break;
      default:
          cout &lt;&lt; "Invalid player ID!\n\n";
          break;
      }
  }
  </code></pre>