Lecture overview -- Keyboard shortcut: 'u'  Previous page: Virtual Functions -- Keyboard shortcut: 'p'  Next page: Hiding inherited names -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Abstraction Mechanisms, Part 2 - slide 6 : 24

Destructors and Inheritance - Virtual Destructors

A class with virtual functions should always have a virtual destructor

prog2.cc
Base class A and derived class B with non-virtual destructors - motivation.
prog2-output
Program output.
prog3.cc
Base class A and derived class B with virtual destructors.
prog3-output
Program output.
prog4.cc
Base class A and derived class B and C with virtual destructors.
prog4-output
Program output.