Lecture overview -- Keyboard shortcut: 'u'  Previous page: Cloning in C# -- Keyboard shortcut: 'p'  Next page: The Visitor design pattern -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Abstract classes, Interfaces, and Patterns - slide 32 : 37

The fragile base class problem

If all methods are virtual it is possible to introduce erroneous dynamic bindings

This can happen if a new method in a superclass is given the same name as a dangerous method in a subclass

fragile.cs
The initial program.
output
Output of original program.
fragile.cs
A revised program with a new version of class A with a method M2.
fragile.cs
The revised version with method A.M2 being virtual.
output
Output of revised program.
fragile.cs
The revised version with method A.M2 being hidden.
output
Output of revised program.