#353 – Why You Might Define an Abstract Class

An abstract class cannot be instantiated and is meant to serve as a base class for other classes.  It might contain implementations for its methods, which derived classes would inherit.  It might also contain one or more abstract methods, with no implementation, which must be overridden in the derived classes.

You’d typically use an abstract class when it would only make sense to instantiate the derived classes and when the base class just serves as a blueprint for the derived classes and to possibly include the implementation of some methods.

For example, you might have a Person class and Man and Woman classes that inherit from Person.  You can imagine only ever creating instances of Man and Woman and never of a generic Person–everyone is either a man or a woman.  You can imagine methods implemented in Person that are common to both men and women, like Sing.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #353 – Why You Might Define an Abstract Class

  1. Pingback: #445 – Differences Between an Interface and an Abstract Class « 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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: