Specialization, Extension, and Inheritance
- slide 36 : 40
Practical use of virtual methods in C#
A client of different types of bank account classes illustrates a typical use of virtual methods
The bank account classes
Use of virtual bank account methods.
Adding interests without use of dynamic binding - AddInterest is not virtual.
Output from the bank account programs.
The use of virtual methods - and dynamic binding - covers a lot of type dispatching which in naive programs are expressed with
if-else
chains