Lecture overview -- Keyboard shortcut: 'u'  Previous page: Member access control: private, public and protected -- Keyboard shortcut: 'p'  Next page: Destructors and Inheritance - Virtual Destructors -- 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 5 : 24

Virtual Functions

A virtual member function in C++ works as expected:

The dynamic type of the receiver controls which function to call.

Destructors may also be virtual, §12.4.2.

To see this image you must download and install the SVG plugin from Adobe.In Firefox please consultthis page.
virtual-1-simplified.cc
Virtual versus non-virtual functions in an AB class hierarchy.
virtual-1-simplified-output
Program output.