O'Reilly logo

Beginning Object-Oriented Programming with C# by Jack Purdum

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16

Inheritance and Polymorphism

What you will learn in this chapter:

  • What inheritance is
  • How inheritance simplifies program code
  • What base classes and derived classes are
  • What the protected access specifier is
  • What polymorphism is
  • How polymorphism can simplify your programs
  • What extension methods are

wrox.com code downloads for this chapter

You can find the Wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118336922 on the Download Code tab. The code in the Chapter16 folder is individually named according to the names throughout the chapter.

This chapter expands the concept of inheritance. Although you have been using inheritance since the first chapter, not much has been said about it. The reason for the delay is because inheritance doesn't make much sense until you understand and appreciate OOP. My guess is that you do see what OOP brings to the table and are ready to dig into the topic of inheritance. In this chapter you learn the details of inheritance necessary to use it properly in your own programs.

As you read this chapter, keep in mind that inheritance was added to OOP languages to make the programmer's life easier. Although the end user may not see any advantages to inheritance and polymorphism, you can have a greater appreciation of how programmers can make program code simpler.

What Is Inheritance?

Until now, inheritance has been a concept sitting in the background, making your life easier every time you designed a user interface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required