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 8070699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:29:11+00:00 2026-06-05T13:29:11+00:00

I have converted a scientific simulation platform from Java into C++. I have tried

  • 0

I have converted a scientific simulation platform from Java into C++. I have tried to keep the design as much as possible the same as previous implementation. In java because of the late binding, circular dependencies are resolved at the run time. However, circular dependencies have created a hell of a mess in C++.

  1. Is there an automated tool which analyses and lists the circular includes and references? (Visual Studio 2010 only issues a huge list of nonsense errors).

  2. I have tried to use forward references wherever possible. However in some occasions both classes need functionality of the other class (i.e. call to methods which makes it impossible to use forward reference). These needs exist in Logic and if I radically change the design they will no more represent real world interactions.

    How could we implement two classes which need each other’s methods and status? Is it possible to implement them in C++?

Examples:

  • Example 1: I have a class called "World" which creates Objects of the type "Agent". Agent needs to call World methods to get information of its environment. World also needs to iterate through Agents and execute their "run" method and get their status (status updates may possibly be done reverse to solve this section of the problem but not the run method).
  • Example 2: Agents create a collection of their "Intentions". Each Agent needs to iterate through its intentions and run/update/read intention status. Intentions also need to get information about the environment through Agent (if done directly through "World" it will create complex circles again) and also info of the Agent itself.

Below diagram shows a sub-set of classes, and some of their methods and properties:

sub-set of classes, and some of their methods and properties

  • 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-06-05T13:29:12+00:00Added an answer on June 5, 2026 at 1:29 pm

    I’m not seeing how forward declarations are not working for you. It looks like you need something like:

    World.h:

    #ifndef World_h
    #define World_h
    
    class Agent;
    
    class World
    {
        World();
        void AddAgent(Agent* agent) { agents.push_back(agent); }
        void RunAgents();
    private:
        std::vector<Agent*> agents;
    };
    
    #endif
    

    Agent.h:

    #ifndef Agent_h
    #define Agent_h
    
    class World;
    class Intention;
    
    class Agent
    {
        Agent(World& world_): world(world_) { world.AddAgent(this); }
        status_t Run();
    private:
        World& world;
        std::vector<Intention*> intentions;
    };
    
    #endif
    

    World.cc:

    #include "World.h"
    #include "Agent.h"
    
    void World::RunAgents()
    {
        for(std::vector<Agent*>::iterator i = agents.begin(); i != agents.end; ++i)
        {
            Agent& agent(**i);
            status_t stat = agent.Run();
            // do something with stat.
        }
    }
    
    // ...
    

    Agent.cc:

    #include "Agent.h"
    #include "World.h"
    #include "Intention.h"
    
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these code which I have converted from Java. Now I need to
I have converted .jpg images into a bitmap thumbnail. What I am trying to
Using explode i have converted the string into array , But the array look
i have just converted an app i was making from a navigation controller app
Have converted devise new session from erb to Haml but doens't work, this is
I have converted an iPhone application using the wizard like thing in XCode into
that i need to have converted into <div id=WhateverHolder> <div class=block> <div class=item first></div>
I have converted one of our existing VC++ project from VS 6.0 to VS
I have converted a Depth Of Field shader from XNA 3.1 to 4.0. The
We have converted our site from HTTP to HTTPS, and when our login forms

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.