title: Array of Generic Class Objects C++
body: <p>I have a  generic class <code>Queue</code> that contains a template <code>Ttype2</code> as the placement holder for the type of data that will be stored in the information field of each node.
   In my driver class I want to instantiate an array of <code>Queue</code> class objects but I can't seem to figure it out. How might I go about doing this?</p>
  
  <p>These didn't work but illustrate what I'm trying to accomplish:</p>
  
  <pre><code>// Queue Complex[] = new Queue();//invalid use of template name without identifier list
   //Queue&lt;Ttype2&gt; Complex[]; //template arg 1 is invalid
  // vector&lt;Queue&gt; Complex2[];//invalid template arguments`
  </code></pre>
  
  <p>Queue Class declaration and constructor inside Queue.h header:</p>
  
  <pre><code>template &lt;typename Ttype2&gt;
  class Queue
  {
    // Global Data Items
    protected:
    Node &lt;Ttype2&gt; Front, Rear;
    int Length;
  
    // member function prototypes
    public:
    Queue();
    void AddRear(Node &lt;Ttype2&gt; ThisNode);
    Node &lt;Ttype2&gt; RemoveFront();
    void Modify(int Position, Node &lt;Ttype2&gt; ThisNode);
    void ClearAll();
    int GetSize();`
    Node &lt;Ttype2&gt; GetNode(int Position);
    Node &lt;Ttype2&gt;* toArray();
  };`
  
  // Constructor
  template &lt;typename Ttype2&gt;
  Queue &lt;Ttype2&gt; :: Queue()
  {
    Rear = Front = NULL;
    Length = 0;
  } // End of Constructor
  `
  </code></pre>