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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:50:54+00:00 2026-06-08T02:50:54+00:00

If I have the following override of a virtual event: void derivedClass::method(event) { //

  • 0

If I have the following override of a virtual event:

void derivedClass::method(event)
{

   // my stuff

   baseClass::method(event); // <--

}

what does the // <— line does? What does it call? I don’t think it calls the base class’ method because it’s virtual (so no body)

  • 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-08T02:50:56+00:00Added an answer on June 8, 2026 at 2:50 am

    As you are suggesting, it calls the base class’ method. The fact that it is virtual it only means it can be overridden and still access to the derived class’ method from a pointer/reference to the base class.

    The reason to do that can be easily seen with an example:

    class Base {
    public:
        virtual void foo() {
            /* do some generic stuff */
        }
    };
    
    class Derived : public Base {
    public:
        void foo() {
            /* do some specific stuff */
    
            /* if you also want to do the generic stuff,
               you can call the same method from the base class. */
            Base::foo();
        }
    }
    

    It might be the case that you do not want to do the generic stuff for Derived class. Then you would just remove the call to Base::foo().

    Here you have a good reference on virtual methods.

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

Sidebar

Related Questions

I have the following method: @Override public boolean myMethod() { // do stuff }
i have the following method in a usercontrol protected override void Render(HtmlTextWriter writer) {
Say I have the following hierarchy: public class MyClass { protected virtual void Method()
I have the following own Interface Implementation in my Fragment: @Override public void onReportChanged(Fragment
I have the following Behavior: public class NavigateAndBroadcastAction : NavigateToPageAction { protected override void
I have the following code: int a = 0; protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
I have the following code: class Visitor { internal virtual void Visit(Node n) {
I have the following code: class MyBase { public virtual void foo() { ...
Lets say we have following sample code in C#: class BaseClass { public virtual
i have the following function to override the default save function in a model

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.