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

  • Home
  • SEARCH
  • 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 8821207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:47:41+00:00 2026-06-14T05:47:41+00:00

I have a base class A that I am extending with X . Inside

  • 0

I have a base class A that I am extending with X. Inside of A there is another class, B. It seems like the virtual method is not being defined, but I don’t understand why?

class A {
 public:
  class B {public: bool value;};

  A() {}
  B b_;
  void DoStuff(B& b);
 private:
  virtual void DoStuffImpl(B& b) = 0;
};

class X : public A {
 public:
  X() {}
  void Trigger();
 private:
  virtual void DoStuffImpl(B& b);
};

void A::DoStuff(B& b) {
     DoStuffImpl(b);
}

void X::Trigger() {
    DoStuff(b_);
}
void X::DoStuffImpl(B& b) {
    b.value = true;
}

int main(){
    X x;
    x.Trigger();
    return x.b_.value;
}

P.S. This came up because I am having a different problem with my code, but I couldn’t even make this toy example work, so now I have this making me curious….

Here is a link to the above code, which is compiling and failing to run: http://ideone.com/mBJ1Kg

  • 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-14T05:47:42+00:00Added an answer on June 14, 2026 at 5:47 am

    It runs fine. ideone reports a “runtime error” with an exit code of 1 because you return 1 from main. A non-zero return code is conventionally considered to be a failure.

    If you comment out your return x.b_.value line and replace it with return 0 then everything’s fine.

    You could have put some std::cout lines in there to see what’s going on, and see that the program works! 😀

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

Sidebar

Related Questions

I have an abstract base class that holds a Dictionary. I'd like inherited classes
I have a base class that looks like the following: template<typename T> class Base
I have a base class that has a method that creates an instance of
I am extending an existing C++ project. I have a base class that derives
I have a Base class that needs a Generic type. That can be either
I have a base class ( car ) and a class that inherit the
Suppose I have a Base class and a Child class that inherits from Base
In the project I'm working on now, we have base Entity class that looks
I have a Generic Base Class that I want to allow one of two
I have a abstract base class that I have many inherited classes coming off

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.