graph implementation: variable has initializer but incomplete type
<p>I am trying to learn C++ and would like to implement some of the algorithms for finding minimum spanning trees in graphs. However, I am having some trouble writing the interface and I don't know where I am going wrong. I get two errors: </p>

<p>error: variable 'Graph::adjIterator it' has initializer but incomplete type</p>

<p>error: expected ',' or ';' before '=' token</p>

<p>graph.h</p>

<pre><code>#ifndef GRAPH_H
#define GRAPH_H

#include&lt;vector&gt;

struct Edge {

    int v, w;
    double weight;
    Edge(int v_, int w_, double weight_ = 1) :
            v(v_), w(w_), weight(weight_) {
    }
};

class Graph {
private:
    int Vcnt, Ecnt;
    bool directedGraph;
    struct Node {

        int v;
        Node* next;
        Node(int v_, Node* next_) :
                v(v_), next(next_) {
        }

    };
    std::vector&lt;Node*&gt; adj;     //this is a linked list ! 

public:
    Graph(int V, bool diGraph = false) :
            adj(V), Vcnt(V), Ecnt(0), directedGraph(diGraph) {
        adj.assign(V, NULL);
    }
    int V() {
        return Vcnt;
    }
    int E() {
        return Ecnt;
    }
    bool directed() const {
        return directedGraph;
    }
    void insert(Edge e) {
        int v = e.v;
        int w = e.w;
        adj[v] = new Node(w, adj[v]);
        if (!directedGraph)
            adj[w] = new Node(v, adj[w]);
        Ecnt++;
    }
    bool egde(int v, int w) const;
//void remove(Edge e);
    class adjIterator;
    friend class adjIterator;
};
</code></pre>

<p>graph.cpp</p>

<pre><code>#include "graph.h"

class Graph::adjIterator {
private:
    const Graph &amp; G;
    int v;
    Node* t;
public:
    adjIterator(const Graph&amp; G_, int v_) :
            G(G_), v(v_) {
        t = 0;
    }
    int begin() {
        t = G.adj[v];
        return t ? t-&gt;v : -1;
    }
    int nxt() {
        if (t)
            t = t-&gt;next;
        return t ? t-&gt;v : -1;
    }
    bool end() {
        return t == 0;
    }
};
</code></pre>

<p>main.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include "graph.h"

int main() {
    Graph G(2);
    Edge e(0, 1);
    G.insert(e);
    for(Graph::adjIterator it(G,0) = it.begin(); it != it.end(); it.nxt()) {
        //stuff 
    }
    return 0;
}
</code></pre>

<p>Thanks in advance for your help.</p>
