#333 – Class Inheritance Leads to a Hierarchy of Classes

Defining a new class, you can specify that it inherits data and behavior from any other existing class, or you can allow the new class to implicitly inherit from System.Object.  Because the new class can inherit from a class that itself inherits from another class, you end up defining a hierarchy of parent / child (base class / derived class) relationships.

Consider the picture shown below.  The user has defined a Dog class, which implicitly inherits from the predefined System.Object class.  They also define the Hound and Terrier classes, both of which inherit from Dog, as well as the FoxTerrier class, which inherits from Terrier.

A class inherits data and methods not only from its immediate parent, but also from other classes higher up in the inheritance chain.  For example, the FoxTerrier class inherits data and methods from Terrier, but also from the Dog class, as well as the System.Object class.

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #333 – Class Inheritance Leads to a Hierarchy of Classes

  1. Pingback: #567 – Wider vs. Narrower Types « 2,000 Things You Should Know About C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 43 other followers