Microsoft Interview Question: Suppose you have a C++ base c... | Glassdoor

Interview Question

Software Development Engineer In Test (SDET) III Interview Redmond, WA

Suppose you have a C++ base class and several classes that

  inherit from it. What might happen if you do not write a virtual destructor for the base class?

Interview Answer

2 Answers


If you reference the derived classes by a pointer of the base class type - the destructor of the derived classes will not be called upon destruction performed using that pointer.

Interview Candidate on Apr 7, 2009

Only the base class destructor would be called and so any pointers/ memory allocated in the derived classes will remain with out being removed.

Sumanth on Feb 9, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.