title: Member variable of subtype of base class in base class
body: <p>Is there a way to do the following with templates?   The following code throws unknown type compile time errors.</p>
  
  <p>I'm trying to create two different types of Application, those that inherit from Application, and those that inherit from Service, which inherits from Application. All Applications have one service called Cron, which will inherit from Service. Applications will be threaded and detached, while Services that derive from Application will be threaded and joined. I broke this down to simplest terms.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Application
  {
  public:
  Service service; //Throws unknown type... Forward decl. will not work either.
  
  };
  
  
  class Service:public Application
  {
  
  
  };
  
  int main(int argc, const char * argv[])
  {
  
  // insert code here...
  std::cout &lt;&lt; "Hello, World!\n";
  return 0;
  }
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>Bruce</p>