English
Topic 9. Inheritance and polymorphism
Goal: become familiar with the inheritance and polymorphism mechanisms in C#; learn to build class hierarchies that call base constructors and use virtual methods and overriding, to override the methods of the object class, and to check object types; master using polymorphic arrays, sealed classes, and custom exceptions.
Lecture contents
- Inheritance and constructors — Inheritance · What is inherited · Derived class constructors
- Virtual methods and polymorphism — Virtual methods and overriding · Polymorphism · Hiding members with new · The object class
- Casting, sealed, and composition — Type casting · Sealed classes and methods · Custom exception classes · Composition versus inheritance
- Examples and common mistakes — Example programs · Common mistakes