Vector of templates
<p>I declared a template for a class and I am trying to use that class as a vector in the subsequent class.
Here is my code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;utility&gt;

using namespace std;

template &lt;typename L&gt;

class AdjacencyListVertex {

public:
    L data;

    vector&lt;int&gt; edges;

    AdjacencyListVertex() {
        data = -1;  
    }

    AdjacencyListVertex(L _data) {
        data = _data;
    }

    void add_edge(int other) {
        edges.push_back(other) ;
    }

    void print(int i) {
        cout &lt;&lt; "  vertex[" &lt;&lt; i &lt;&lt; "] '" &lt;&lt; data &lt;&lt; "' connected to:";
        for (int j = 0; j &lt; edges.size(); j++) {
            cout &lt;&lt; " " &lt;&lt; edges.at(j);
        }
        cout &lt;&lt; endl;
    }
};

template &lt;typename L&gt;
class AdjacencyListGraph {
  public:
      vector&lt;typedef AdjacencyListVertex*&gt; vertices;

    AdjacencyListGraph(int size) {
        vertices = vector&lt;typedef AdjacencyListVertex*&gt; (size, AdjacencyListVertex&lt;L&gt;());
    }

    void add_vertex(int position, L data) {
        vertices.at(position) = AdjacencyListVertex&lt;L&gt;(data);
    }


    void add_edge(int vertex1, int vertex2) {
        vertices.at(vertex1).add_edge(vertex2);
    }

    void print() {
        cout &lt;&lt; "AdjacencyListGraph:" &lt;&lt; endl;
        for (int i = 0; i &lt; vertices.size(); i++) {
            if (vertices.at(i).data != -1) vertices.at(i).print(i);
        }
    }
};



int main(int argc, char** argv) {


    AdjacencyListGraph&lt;string&gt; alg_str = AdjacencyListGraph&lt;string&gt;(5);

    alg_str.add_vertex(0, "alg_str vertex 0");
    alg_str.add_vertex(1, "alg_str vertex 1");
    alg_str.add_vertex(2, "alg_str vertex 2");
    alg_str.add_vertex(3, "alg_str vertex 3");
    alg_str.add_vertex(4, "alg_str vertex 4");

    alg_str.add_edge(0, 1);
    alg_str.add_edge(1, 0);
    alg_str.add_edge(1, 3);
    alg_str.add_edge(3, 4);


}
</code></pre>

<p>I keep getting the errors:</p>

<pre><code>graphs.cpp:38: error: template argument 1 is invalid
graphs.cpp:38: error: template argument 2 is invalid
graphs.cpp: In constructor ‘AdjacencyListGraph&lt;L&gt;::AdjacencyListGraph(int)’:
graphs.cpp:41: error: template argument 1 is invalid
graphs.cpp:41: error: template argument 2 is invalid
graphs.cpp: In member function ‘void AdjacencyListGraph&lt;L&gt;::add_vertex(int, L)’:
graphs.cpp:48: error: request for member ‘at’ in ‘((AdjacencyListGraph&lt;L&gt;*)this)-    &gt;AdjacencyListGraph&lt;L&gt;::vertices’, which is of non-class type ‘int’
graphs.cpp: In member function ‘void AdjacencyListGraph&lt;L&gt;::add_edge(int, int)’:
graphs.cpp:55: error: request for member ‘at’ in ‘((AdjacencyListGraph&lt;L&gt;*)this)-&gt;AdjacencyListGraph&lt;L&gt;::vertices’, which is of non-class type ‘int’
graphs.cpp: In member function ‘void AdjacencyListGraph&lt;L&gt;::print()’:
</code></pre>

<p>Its an error in the line:
vector vertices;</p>

<p>What mistake am I doing in the definition of the vector?</p>
