I work for my homework in C ++, and I have some problems with multiplied definitions.
My graph class;
class Graph{
private:
string name;
fstream* graphFile;
protected:
string opBuf;
int containsNode(string);
Node* nodes;
int nofNodes;
public:
static int nOfGraphs;
Graph();
Graph(int);
Graph(string);
Graph(const Graph &);
~Graph();
string getGraphName();
bool addNode(string);
bool deleteNode(string);
bool addEdge(string,string);
bool deleteEdge(string,string);
void intersect(const Graph&);
void unite(const Graph&);
string toString();
void acceptTraverse(BreadthFirst*);
void acceptTraverse(DepthFirst *);
};
and my bypass class;
class Traversal {
public:
string *visitedNodes;
virtual string traverse (const Graph & );
};
class BreadthFirst : public Traversal {
public :
BreadthFirst();
string traverse();
};
class DepthFirst : public Traversal {
public :
DepthFirst();
string traverse();
};
My problem is in the traversal class, I need to declare the Graph class at the same time, in the graph class I need a traversal class to declare.
I have big problems with declerations :) Could you help me?
source
share