What is a virtual destructor?

Answers were Sorted based on User's Feedback



What is a virtual destructor?..

Answer / munendra kumar

The simple answer is that a virtual destructor is one that is declared with the virtual attribute.

The behavior of a virtual destructor is what is important. If you destroy an object through a pointer or reference to a base class, and the base-class destructor is not virtual, the derived-class destructors are not executed, and the destruction might not be complete.

Is This Answer Correct ?    0 Yes 0 No

What is a virtual destructor?..

Answer / nakul kumar

The simple answer is that a virtual destructor is one that is declared with the virtual attribute.

The behavior of a virtual destructor is what is important. If you destroy an object through a baller or reference to a base class, and the base-class destructor is not virtual, the derived-class destructors are not executed, and the destruction might not be complete.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Where is atoi defined?

0 Answers  


What is c++ code?

0 Answers  


What are the different types of polymorphism in c++?

0 Answers  


What do you mean by abstraction in C++?

1 Answers  


Describe new operator?

0 Answers  






What is the basic concept of c++?

0 Answers  


What is the Difference between "vector" and "array"?

15 Answers   Covansys, Gambit, TCS, Wipro,


1)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea += sizeof(int); } return 0; } 2)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea ++; } return 0; } The output of this two programs will be different why?

5 Answers  


Define basic type of variable used for a different condition in C++?

0 Answers  


How do we implement inheritance in c++?

0 Answers  


If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?

0 Answers  


What is the benefit of learning c++?

0 Answers  


Categories