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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:13:14+00:00 2026-06-17T22:13:14+00:00

I am working on a project that had been thought out, rather poorly. I

  • 0

I am working on a project that had been thought out, rather poorly. I have subclasses that access each other’s member functions. Here’s the situation:

class A {
public:
    class B;
    class C;
};

class A::B {
public:
    void f() {
        C:g();
    }
}
class A::C {
public:
    void g() {
        B:f();
    }
}

This code, obviously, runs into various errors which is too much list here. My question is, what is the solution to such a situation? Is it inheritance? If so, how? Is there any other way for me to preserve the “interplaying”-nature of classes B and C.

  • 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-17T22:13:15+00:00Added an answer on June 17, 2026 at 10:13 pm

    If you mean C:g() –> C::g(), B:f() –> B::f()

    You can not call member function without object unless these member functions are static.
    Probably a pointer to each other may resolve your issue?
    I introduce pointer is because otherwise I need to write something to help with circular include issue. 🙂

    #include <memory>
    
    class A::B {
    public:
        void f() {
            c_->g();
        }
      std::unique_ptr<C> c_;
    }
    class A::C {
    public:
        void g() {
            b_->f();
        }
      std::unique_ptr<B> b_;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a project that has had a long history of development. There have
I'm working on a project that involves a simple web service, and have had
I have a project that I am working on and I can't figure out
I am working on a project that I had been compiling with LLVM 2.6
I have a working project that Im amending, it crashes after trying to use
maybe you can help me out. I'm working on an Android app project that
So I have been working on a project using Entity Framework 5 in development
I am working on a data warehousing project, and therefore, I have been implementing
I had been working on a cocos2d-x project for the QNX platform and I
I have a project that has, amongst other things, one web application (mvc) and

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.