Problem with OOP Class Definitions

Posted by oben on Stack Overflow See other posts from Stack Overflow or by oben
Published on 2010-04-30T04:28:40Z Indexed on 2010/04/30 4:37 UTC
Read the original article Hit count: 252

Filed under:
|
|
|

Hi, this is Oben from Turkey.

I work for my homework in C++ and i have some problems with multiply definitions.

My graph class ;

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 *);

};

and my traversal 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 traversal class , i need to declare Graph class at the same time , in graph class i need traversal class to declare.

I have big problems with declerations :) Could you please help me ?

© Stack Overflow or respective owner

Related posts about c++

Related posts about oop