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

The Archive Base Latest Questions

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

Parent class has a Virtual function. Is it necessary to have a virtual destructor

  • 0

Parent class has a Virtual function. Is it necessary to have a virtual destructor in the parent class ?

So the questions are
1. Now considering rule of three , should we declare the other two?

  • 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-08T13:43:55+00:00Added an answer on June 8, 2026 at 1:43 pm

    A virtual destructor is required any time delete is called on a pointer to that class where the object being deleted is actually of a more derived type. If your base class may be used in this sort of situation then you must provide a virtual destructor.

    It is usually advisable to add a virtual destructor to any class that has virtual functions as this gives safety and flexibility to future users of the class and the additional cost of adding a virtual destructor to an already polymorphic class is typically low.

    This last rule is just a rule of thumb, though. It may be necessary to have a virtual destructor in a class even if it doesn’t have any other virtual functions and, conversely, a virtual destructor may not be needed for a polymorphic class if it is never used in a context that requires this (typically the destructor would be made protected or even private to enforce this).

    You only need to provide a user-defined copy constructor and a copy assignment operator if the compiler provided default implementations won’t do the correct thing. If you’ve added a destructor with an empty implementation purely to make it virtual, this is unlikely to have any bearing on the need for you to provide a copy constructor and a copy assignment operator.

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

Sidebar

Related Questions

I have one parent class, which is abstract class for now, for four different
I have the following: class Parent { public: virtual bool foo(vector<string> arg1, vector<string> arg2)
I have two classes: public class Parent { public virtual long? ID { get;
In a situation where you have a parent class which has one child class,
I have two classes with a parent-child relationship (the Parent class has-a Child class),
Can someone help me understand variable/function inheritance in PHP classes. My parent class has
I have the following two models: class Parent < ActiveRecord::Base has_one :child, dependent: :destroy
I have a parent class which contains a child object. I am using set
I have a parent class and child class (inherited from parent). In the child
I have a MustInherit Parent class with two Child classes which Inherit from the

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.