Chapter 6. Understanding Inheritance and Polymorphism

The previous chapter examined the first pillar of OOP: encapsulation. At that time you learned how to build a single well-defined class type with constructors and various members (fields, properties, constants, read-only fields, etc.). This chapter will focus on the remaining two pillars of OOP: inheritance and polymorphism.

First, you will learn how to build families of related classes using inheritance. As you will see, this form of code reuse allows you to define common functionality in a parent class that can be leveraged (and possibly altered) by child classes. Along the way, you will learn how to establish a polymorphic interface into the class hierarchies using virtual and abstract members. ...

Get Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.