我正在做C++的作业,遇到了一些关于多重定义的问题。
我的图形类:
class Graph{
private:
string name; //Graph name
fstream* graphFile; //Graph's file
protected:
string opBuf; //Operations buffer
int containsNode(string); //Query if a node is present
Node* nodes; //Nodes in the graph
int nofNodes; //Number of nodes in the graph
public:
static int nOfGraphs; //Number of graphs produced
Graph(); //Constructors and destructor
Graph(int);
Graph(string);
Graph(const Graph &);
~Graph();
string getGraphName(); //Get graph name
bool addNode(string); //add a node to the graph
bool deleteNode(string); //delete a node from the graph
bool addEdge(string,string); //add an edge to the graph
bool deleteEdge(string,string); //delete an edge from the graph
void intersect(const Graph&); //intersect the graph with the <par>
void unite(const Graph&); //intersect the graph with the <par>
string toString(); //get string representation of the graph
void acceptTraverse(BreadthFirst*);
void acceptTraverse(DepthFirst *);
};
和我的遍历类一起;
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();
};
我的问题出现在遍历类中,我需要同时声明图形类,在图形类中我需要遍历类来声明。
我在声明方面遇到了很大的问题:) 你能帮我吗?