Dynamic binding
A simple view of the problem
Why do we care?
An obvious solution
The obvious solution can be made to work
Implementation (in C)
Using the type code
What’s wrong with the simple approach?
The C++ approach: virtual functions
The function definitions look normal
Calling a virtual function
Examples
A virtual call happens when
Typical implementation
Types of virtual functions
An example
The data structure
Example code, part 1
Code, part 2
Code, part 3
Adding new shapes
Draw all the shapes
Why the virtual destructor?
What does a virtual destructor do?
Multiple abstractions
Virtual functions and type fields
Virtual functions and constructors
Why aren’t all member functions virtual?
Summary
Email: ark@research.att.com
Home Page: http://www.research.att.com/info/ark