title: C++ abstract class template
body: <p>I have the following code:</p>
  
  <pre><code>template &lt;typename T&gt;
  class ListBase
  {
  protected:
      int _size;
  public:
      ListBase() {_size=0;}
      virtual ~ListBase() {}
      bool isEmpty() {return (_size ==0);}
      int getSize() {return _size;}
  
      virtual bool insert(int index, const T &amp;item) = 0;
      virtual bool remove(int index) = 0;
      virtual bool retrieve(int index, T &amp;item) = 0;
      virtual string toString() = 0;
  };
  </code></pre>
  
  <p>My second file defines a subclass:</p>
  
  <pre><code>#define MAXSIZE 50
  template &lt;class T&gt;
  class ListArray : public ListBase
  {//for now to keep things simple use int type only later upgrade to template
  private:
      T arraydata[MAXSIZE];
  public:
  
      bool insert(int index,const T &amp;item)
      {
          if(index &gt;= MAXSIZE)
              return false;//max size reach
          if (index&lt;0 || index &gt; getSize() )//index greater than array size?
          {
              cout&lt;&lt;"Invalid index location to insert"&lt;&lt;endl;
              return false;//invalid location
          }
  
          for(int i = getSize()-1 ; i &gt;= index;i--)
          {//shift to the right
              arraydata[i+1]=arraydata[i];
          }
          arraydata[index] = item;
          _size++;
          return true;
      }
  
      string ListArray::toString()
      {
          ostringstream ostr;
          ostr&lt;&lt;"[";
          for(int i = 0; i &lt; _size;i++)
              ostr&lt;&lt;arraydata[i]&lt;&lt;' ';
          ostr&lt;&lt;"]"&lt;&lt;endl;
          return ostr.str();
      }
  };
  </code></pre>
  
  <p>My main.cpp:</p>
  
  <pre><code>int main()
  {
      ListArray&lt;char&gt; myarray;
      myarray.insert(0,'g');
      myarray.insert(0,'e');
      myarray.insert(1,'q');
      cout&lt;&lt;myarray.toString();
  }
  </code></pre>
  
  <p>I can't seem to figure out how to use a template with a subclass.  When I compile my code, I get the following error:</p>
  
  <blockquote>
    <p>error C2955: 'ListBase' : use of class template requires template argument list
    see reference to class template instantiation 'ListArray' being compiled</p>
  </blockquote>