1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. Why should a base class used polymorphically have a…

Added 30 Nov -0001

Why should a base class used polymorphically have a virtual destructor?

  1. So derived classes skip the base destructor
  2. So the object is reclaimed by a collector
  3. So deleting through a base pointer is complete Correct answer
  4. So the destructor may be called twice

Correct answer

C. So deleting through a base pointer is complete

14 views

MCQSEXAM

Explanation

Without a virtual destructor, deleting via a base pointer is undefined behaviour and skips the derived destructor.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs