employer cover photo
employer logo
employer logo

Amazon Lab126

Part of Amazon

Is this your company?

Amazon Lab126 Interview Question

What is a virtual destructor and why would you use it?

Interview Answer

Anonymous

Jun 9, 2014

A virtual destructor is when the base class destructor has no definition and can be overridden by the derived class. When an object is deleted, the base class destructor does not call the derived class destructor. Declaring the base class destructor as virtual resolves this issue.