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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:35:44+00:00 2026-06-07T22:35:44+00:00

Possible Duplicate: Why does an overridden function in the derived class hide other overloads

  • 0

Possible Duplicate:
Why does an overridden function in the derived class hide other overloads of the base class?

Hi,

Let me explain my question with this example :

class A
{
    virtual ~A() = 0 { }

    A(const A&);
    virtual void operator =(const A&) = 0;
}

class B : public A
{
    ~B();

    B(const B&);
    void operator =(const B&);
}

void main(void)
{
    A* a = new B();
    delete a; // Is ~A() called, ~B() or both ?
}

This brings me to ask two questions :

  1. Which destructor is called when using delete on an abstract-base-class pointer ?
  2. Is it possible to make a copy of my object “a” with one of the copy methods above ?
  • 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-07T22:35:45+00:00Added an answer on June 7, 2026 at 10:35 pm
    1. Both are called.

      In delete a the derived class destructor ~B::B is found and called using the virtual dispatch mechanism. The implementation of ~B::B in turn implicitly calls the base class destructor ~A::A. However, this call is implemented as non-virtual ordinary call, meaning it is not affected by the fact that ~A::A is declared as pure.

      This is actually the reason why pure virtual destructors still have to be defined. Although the language specification does not permit in-class definitions for pure virtual functions. Even if you want it to be inline, you still have to define it out of class.

    2. It is not possible to copy a standalone object of type A simply because there can’t be any standalone object of abstract type. Please, clarify your question. What do you want to copy and to where?

      If you want to do something like this

      B b1, b2;
      A *a1 = &b1, *a2 = &b2;
      
      *a1 = *a2;
      

      and expect the last assignment to behave as if b1 = b2 was performed… well, it can be done but it will take some effort and might/will result in pretty ugly code. I’d say that burdening the overloaded assignment operator with that sort of functionality is not a good idea.

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

Sidebar

Related Questions

Possible Duplicates: C++ overload resolution Why does an overridden function in the derived class
Possible Duplicate: What does this “(function(){});”, a function inside brackets, mean in javascript ?
Possible Duplicate: How does this CSS triangle shape work? Please help me i need
Possible Duplicate: What does the question mark and the colon (?: ternary operator) mean
Possible Duplicates: C++ method only visible when object cast to base class?! Why does
Possible Duplicate: Does Java guarantee that Object.getClass() == Object.getClass()? If I have a class
Possible Duplicate: Why does defining getitem on a class make it iterable in python?
Possible Duplicate: What is the best algorithm for an overridden System.Object.GetHashCode? This is known
Possible Duplicate: Does a finally block always run? let's imagine the following scenario: public
Possible Duplicate: 'Delegate 'System.Action' does not take 0 arguments.' Is this a C# compiler

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.