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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:45:18+00:00 2026-06-02T02:45:18+00:00

First: I know my question is not about a parent class, but I don’t

  • 0

First: I know my question is not about a parent class, but I don’t know how this structure is called and I thought parent would be the easiest to describe it.

I have two classes defined like this:

class class_a {
    void foo() {
        //stuff
    }
};

class class_b {
    class_a A;
    void foo() {
        //more stuff
    }
};

I want class_b::foo(); called when certain requirements are met in class_a::foo(); It’s possible to just set a variable in class_a and check for it in class_b::foo(); but I was wondering if there is a more elegant solution to this.

note: class_b is and can not be derived from class_a.

  • 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-02T02:45:19+00:00Added an answer on June 2, 2026 at 2:45 am

    Not sure I completely understand what you are trying to do, a more concrete example would be helpful, but perhaps this does what you want:

    class class_b;
    
    class class_a {
        void foo(class_b* b);
    };
    
    class class_b {
        class_a A;
        void foo() {
            A.foo(this);
        }
        void foo_impl() {
            // stuff based on requirements in a::foo
        }
    };
    
    void class_a::foo(class_b* b) {
        //stuff
        if (conditionsMet()) {
            b->foo_impl();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question here :) I know that I should not check
First, my question is not about password hashing, but password encryption. I'm building a
First of all, this is not a question about how to get the user's
Well this is not the first time im asking these question here but I
First of all, I'm not so sure about how to ask this question. I
First: apologies for the question title, I don't actually know what the problem is
This is a two-part question: First, I am interested to know what the best
To begin with, I don't know the first thing about Python ... so I
This is not a question about how to sign an .apk file. I want
First of all, I know there are a lot of questions about this topic.

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.