Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 772197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:46:20+00:00 2026-05-14T18:46:20+00:00

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

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:46:21+00:00Added an answer on May 14, 2026 at 6:46 pm

    No you don’t need the definition of the classes. You just need to give the hint to the compiler that Graph and Traversal are classes. So use forward declartion like class BreadthFirst; in the definition of Graph (i..e just above class Graph{….}). Similarly use class Graph; before the definition of Traversal class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on some homework for my compiler class and I have the following
(This is no homework and no work issue. It's just my personal interest/occupation and
I work in VBA, and want to parse a string eg <PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
At work, we have multiple branches that we may be working on at any
I have done a homework assignment, here is the problem statement: Your program should
At work we are currently still using JUnit 3 to run our tests. We
At work we are being asked to create XML files to pass data to
I work with C# at work but dislike how with webforms it spews out
I work on a complex application where different teams work on their own modules
I work for a .NET/MSSQL shop that has trouble supporting customers running Novell, partially

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.