top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

C++: Why destructor is defined as virtual in a derived class ?

0 votes
40 views
C++: Why destructor is defined as virtual in a derived class ?
posted Oct 1, 2018 by Vikram Singh

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
I think it should be base class ?

In case, the derived class object ( accessed via the pointer to base class) is deleted, will result in undefined behaviour. (if the base destructor is not virtual). To avoid this, the base class destructor is made virtual.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...