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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:50:49+00:00 2026-05-26T19:50:49+00:00

class base_c { public virtual void a() {} public virtual void b() {} public

  • 0
class base_c
{
    public virtual void a() {}
    public virtual void b() {}
    public virtual void c() {}
    public virtual void d() {}
}

class other_c : base_c
{
    public void a() {}
    public new void b() {}
    public override void c() {}
    public override void d() {base.d();}
}

class Program
{
    static void Main()
    {
        base_c game2 = new other_c();
        game2.a();
        game2.b();
        game2.c();
        game2.d();
    }
}

‘d’ has the desired behaviour that the more general base_c function occurs as well as the more specific other_c, although it would nice if the order was the other way round. To see this in effect, use the debugger and step though the program.

Is ‘d’ the best way to achieve this result?

Although it could be changed in this example “base_c game2 = …” must remain base_c and cannot be changed to other_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-05-26T19:50:49+00:00Added an answer on May 26, 2026 at 7:50 pm

    Yes, if your intent is for the child class to extend the inherited behavior in method D, then the pattern is to call base.d() in the child’s override of d.

    If your intent is to replace the inherited behavior (not extend), then you would not call the base method.

    You also have the choice of whether to call the base method first before doing anything in your overriding method, or call the base in the middle or after your code in your overriding method.

    All of these are valid techniques in the appropriate situations.

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

Sidebar

Related Questions

Suppose I have this class hierarchy: class A { public: virtual void foo(Base *b)
In a C# program, I have an abstract base class with a static Create
class Base { public: Base(){} Base(int k):a(k) { } int a; }; class X:virtual
Given a base class with the following interface: public class Base { public virtual
In C++, you can do the following: class base_class { public: virtual void do_something()
#include<iostream> using namespace std; class Abs { public: virtual void hi()=0; }; class B:public
I have this setup: class A { public: virtual void Function(); } class B
I have a base class MyBase that contains a pure virtual function: void PrintStartMessage()
I have a base interface class: class A { public: ITask(){} virtual bool Start()=0;
I have these classes in C# (.NET Framework 3.5) described below: public class Base

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.