Here's my code that's supposed to be a basic graph implementation using adjacency lists. It comes straight from R.Sedgewick's "Algorithms in C++".
However "23 - ISO C++ forbids declaration of `vector' with no type ". Why is that?
However "23 - ISO C++ forbids declaration of `vector' with no type ". Why is that?
Code:
class graf
{
struct edge
{
int v, w;
edge(int v = -1, int w = -1) : v(v), w(w) {}
};
struct node
{
int v; node* next;
node(int x, node* t) {v = x; next = t; }
};
typedef node* link;
vector <link> adj;
public:
graf(int V) : adj(V) {adj.assign(V,0);}
int insert(edge e)
{
int v = e.v, w=e.w;
adj[v] = new node(w, adj[v]);
adj[w] = new node(v, adj[w]);
}
void remove(edge e);
bool edge(int v,int w) const;
class adjIterator;
friend class adjIterator;
};
Comment