title: Getting undefined class type error but I did create the class and defined it
body: <p>Im working on an assignment for one of my classes. Simply I have a GumballMachine class and a bunch of State classes that change the state of the GumballMachine.</p>
  
  <p>Here is the offending code:</p>
  
  <pre><code>class GumballMachine;
  
  class State {
  public:
   virtual void insertQuarter() const = 0;
   virtual void ejectQuarter() const = 0;
   virtual void turnCrank() const = 0;
   virtual void dispense() const = 0; 
  
  protected:
   GumballMachine *GBM;
  };
  
  class NoQuarterState : public State {
  public: 
   NoQuarterState (GumballMachine *GBM) {
    this-&gt;GBM = GBM;  
   }
  
   void insertQuarter() const {
    cout &lt;&lt; "You inserted a quarter\n";  
    **this-&gt;GBM-&gt;QuarterInserted();** // &lt;--- C2027 error on MSDN  
   }
  };
  </code></pre>
  
  <p>Now further below I have defined my GumballMachine class as:</p>
  
  <pre><code>class GumballMachine {
  public:
   GumballMachine(int numOfGB) {
    this-&gt;noQuarterState = new NoQuarterState(this);
    this-&gt;soldOutState = new SoldOutState(this);
    this-&gt;hasQuarterState = new HasQuarterState(this);
    this-&gt;soldState = new SoldState(this);
    this-&gt;winnerState = new WinnerState(this);
    this-&gt;count = numOfGB;
    if (0 &lt; numOfGB) {
     this-&gt;state = this-&gt;noQuarterState;
    }
    else {
     this-&gt;state = this-&gt;soldOutState;
    }  
   }
  
          ... more code ...
  
   void QuarterInserted() {
    this-&gt;state = this-&gt;hasQuarterState;
   }
  
   ... more code ...
  
  protected:
   int count;
   NoQuarterState *noQuarterState;
   SoldOutState *soldOutState;
   HasQuarterState *hasQuarterState;
   SoldState *soldState;
   WinnerState *winnerState;
   State *state;
  };
  </code></pre>
  
  <p>Visual Studios was throwing a C2259 and C2027 error but after looking at MSDN I feel like I am doing it right. Maybe I am just tired, but I can't seem to find the error/see what I did wrong.</p>
  
  <p>Much thanks to any help. :D</p>