How can I make a parent instantiate its child?
<p>I have a parent class test with child classes that are sub-tests.  When I call test->run() I want to run all my sub tests.  The code below does not work b.c. the child class is not recognized in the parent class.</p>

<pre><code>using namespace std;
  class test
    {
    protected:
      short verbosity_;
    public:
      void setVerbosity(short v)
        {
        if((v==0 || v==1 || v==2)) 
          {
          verbosity_ = v;
          }
        else 
          {
          cout &lt;&lt; " Verbosity Level Invalid " &lt;&lt; endl;
          }
        }
      void run()
        {
        natives natives_1; // this does not work
      }
    };
  class natives : public test 
    {
    public:
      natives()
        {
        this-&gt;run();
        }
      void run()
       {
       testInts&lt;short&gt;();
       testInts&lt;int&gt;();
       testInts&lt;long&gt;();
       testInts&lt;unsigned short&gt;();
       testInts&lt;unsigned int&gt;();
       testInts&lt;unsigned long&gt;();
       }         
    protected:
      template&lt;class T&gt; void testFloats()
        {
        }
      template&lt;class T&gt; void testInts()
        {
        short passState, bitDepth;
        T failMax, pow2 = 1, minValue = 0, maxValue = 0, bitCount = 0, failValue = 0;  
        const char* a = typeid(T).name();
        bool signedType = ((*a == 't') || (*a == 'j') || (*a == 'm'));
        while(pow2 &gt; 0)
          {
          pow2 *= 2;
          bitCount++;
          }
        maxValue = pow2-1;
        failValue = pow2;
        int native1 = bitCount;
        int native2 = sizeof(T)*8;
        int native3 = numeric_limits&lt;T&gt;::digits;  
        if( !signedType )
          {
          native1++;
          native3++;
          }       
        if(verbosity_&gt;=1) cout &lt;&lt; endl &lt;&lt; "**********\n" &lt;&lt; reportType(a) &lt;&lt; "\n**********" &lt;&lt; endl &lt;&lt; endl;
        if ((native1 == native2) &amp;&amp; (native1 == native3))
          {
          if(verbosity_&gt;=1)cout &lt;&lt; "Correlation:\t\tPass: " &lt;&lt; native1 &lt;&lt; endl ;
          if(verbosity_&gt;=2)
          {
            cout &lt;&lt; "--Algorithm:\t\t" &lt;&lt; native1 &lt;&lt; endl;
            cout &lt;&lt; "--Sizeof:\t\t" &lt;&lt; native2 &lt;&lt; endl;
            cout &lt;&lt; "--Reported:\t\t" &lt;&lt; native3 &lt;&lt; endl;
            cout &lt;&lt; "----Max Value:\t\t" &lt;&lt; maxValue &lt;&lt; endl;
            cout &lt;&lt; "----Max+1\t\t" &lt;&lt; failValue &lt;&lt; endl;
            } 
         else
            {
            }
          }
        else
          {
          cout &lt;&lt; "Correlation:\t\tFail" &lt;&lt; endl ;
          }
        }
      string reportType(const char* c1)
        { 
        string s1;
        switch(*c1)
          {
          case 't':
            s1 = "Unsigned short";
            break;
          case 'j':
            s1 = "Unsigned int";
            break;
          case 'm':
            s1 = "Unsigned long";
            break;
          case 's':
            s1 = "Short";
            break;
          case 'i':
            s1 = "Int";
            break;
          case 'l':
            s1 = "Long";
            break;
          default:
            s1 = "Switch failed";
          }
        return s1;
        }
};
</code></pre>
