title: Declaring variables of abstract type in C++
body: <p>I'd want to define a general class with some functions and nested classes with virtual functions:</p>
  <pre><code>class c_foo {
      public:
          class c_subfoo {
              public:
                  virtual int do_subfoo(void) = 0;
                 
          };
  
          int do_foo(void);
  };
  </code></pre>
  <p>The function <em>c_foo::do_foo()</em> would call functions in the nested class <em>c_foo::c_subfoo</em>:</p>
  <pre><code>int c_foo::do_foo(void) {
      c_subfoo subfoo;
      subfoo.do_subfoo();
      return 0;
  };
  </code></pre>
  <p>However I <em>cannot declare variable 'subfoo' to be of abstract type 'c_foo::c_subfoo' because c_foo::c_subfoo::do_subfoo is a pure virtual function</em>.</p>
  <p>How can I define <em>c_foo::do_foo()</em>, which is always the same for all derived classes and that calls <em>c_foo::c_subfoo</em> functions, without defining these <em>c_foo::c_subfoo</em> functions, which are different in each derived class?</p>