CHAPTER 7

image

Creating Class Hierarchies

In Chapter 6, you learned how to create classes, add attributes and methods, and instantiate object instances of the classes in client code. This chapter introduces the concepts of inheritance and polymorphism.

Inheritance is one of the most powerful and fundamental features of any OOP language. Using inheritance, you create base classes that encapsulate common functionality. Other classes can be derived from these base classes. The derived classes inherit the properties and methods of the base classes and extend the functionality as needed.

A second fundamental OOP feature is polymorphism. Polymorphism ...

Get Beginning C# Object-Oriented Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.