title: Stack of class member functions but the class isn't known yet
body: <p><em>I have something a little tricky to explain so I'll try my best. I have an InstructionScreen class that displays arrows &amp; blocks of text that explain what each buttons does &amp; etc. So in InstructionScreen I have a stack of member functions each of those functions will create some arrows &amp; text to explain what a different button does.</em></p>
  
  <p>The InstructionScreen will be subclassed into MenuInstructScreen, OptionsInstructScreen &amp; etc. and in these classes I will create custom functions that will create arrows &amp; text to explain their screens buttons.</p>
  
  <p><strong>The problem is declaring this stack in InstructionScreen because it will contain functions that are part of their subclass. I am thinking I can do this, but I use templates right?</strong></p>
  
  <p><strong>So the problem in a nutshell is how do I declare a stack that will contain member functions of a class that doesn't exist yet?</strong></p>
  
  <p>The problem is a lot easier to understand &amp; see if you look at this simple example:  </p>
  
  <pre><code>typedef class InstructionScreen;
  typedef class MenuInstructScreen;
  template &lt;typename FooClass&gt;
  typedef void (FooClass::*MemberFuncPtr)();   // will be typedef void (MenuInstructScreen::*MemberFuncPtr)();
  
  
  class InstructionScreen
  {
       public:
           InstructionScreen() {}
  
           void runInstructions()
           {
                while ( !instructionStep.empty() )
                {
                    (this-&gt;*instructionStep.top())(); 
                    instructionStep.pop();
                }
           }
  
       protected:
            stack &lt;MemberFuncPtr&gt; instructionStep; 
  };
  
  class MenuInstructScreen : public InstructionScreen
  {
      public:
         MenuInstructScreen() 
         {
            // Set instruction schedule
            instructionStep.push( &amp;MenuInstructScreen::step2() ); 
            instructionStep.push( &amp;MenuInstructScreen::step1() );              
         }
  
         void step1()
         {
              // create some widgets that point to buttons &amp; widgets that contain text instructions 
         }
  
         void step2()
         {
              // create some widgets that point to buttons &amp; widgets that contain text instructions 
         }
  
      private:
  
  };
  
  class OptionsInstructScreen : public InstructionScreen
  {
      public:
         OptionsInstructScreen() 
         {
            // Set instruction schedule
            instructionStep.push( &amp;OptionsInstructScreen::step2() ); 
            instructionStep.push( &amp;OptionsInstructScreen::step1() );              
         }
  
         void step1()
         {
              // create some widgets that point to buttons &amp; widgets that contain text instructions 
         }
  
         void step2()
         {
              // create some widgets that point to buttons &amp; widgets that contain text instructions 
         }
  
      private:
  
  };
  </code></pre>