title: C++ Class Entanglement
body: <p>I'm trying to use two classes' variables as to have access from class A's variables to class B's and vice versa. However, I can't figure a possible solution. It always ends up in either a loop, or the following error:</p>
  
  <pre><code>error: invalid use of non-static data member  
  </code></pre>
  
  <p>Here's the code sample:    </p>
  
  <p>Player.h:</p>
  
  <pre><code>  #ifndef _PLAYER_H_
    #define _PLAYER_H_
  
  #include "Segment/Dynamic_Segment.h"
  
  class Attributes_P;
  
  class Attributes_P : public Attributes_DS{
    protected:
    int inv_mcols, inv_mrows;
  
    public:
    Attributes_P();
    void controls( int MKEY_UP, int MKEY_RIGHT, int MKEY_DOWN, int MKEY_LEFT );
    void inventory( int inv_mcols, int inv_mrows );
  };
  
  class Player : public Dynamic_Segment{
    protected:
    int   **inv;
  
    public:
  
    int   MKEY_UP, MKEY_RIGHT, MKEY_DOWN, MKEY_LEFT;
  
    public:
  
    Player();
    Attributes_P set;
    friend class Core;
    friend class Attributes_P;
  
  };
  #endif
  </code></pre>
  
  <p>Player.cpp:</p>
  
  <pre><code>#include "Segment/Player.h"
  
  Attributes_P::Attributes_P(){};
  
  Player::Player() : Dynamic_Segment(){
    set.inv_mcols = 0;
    set.inv_mrows = 0;
  }
  
  void Attributes_P::inventory( int inv_mcols, int inv_mrows ) {
    this-&gt;inv_mcols = inv_mcols;
    this-&gt;inv_mrows = inv_mrows;
    Player::inv = new int*[this-&gt;inv_mcols]; //&lt;--- Error here
    for( int i = 0; i &lt; this-&gt;inv_mrows; i++ ) {
      Player::inv[i] = new int[this-&gt;inv_mcols]; //&lt;--- Error here
    }
  }
  
  void Attributes_P::controls( int MKEY_UP, int MKEY_RIGHT, int MKEY_DOWN, int MKEY_LEFT ) {
    Player::MKEY_UP = MKEY_UP; //&lt;--- Error here
    Player::MKEY_RIGHT = MKEY_RIGHT; //&lt;--- Error here
    Player::MKEY_DOWN = MKEY_DOWN; //&lt;--- Error here
    Player::MKEY_LEFT = MKEY_LEFT; //&lt;--- Error here
  }
  </code></pre>
  
  <p>Have been banging my head against a wall for some time now... Any ideas would be appreciated!</p>