What if you were writing a class that you wanted to be a base class? A class designed from the very beginning to bring together other classes with common behavior. What if you also wanted to guarantee that this class could never be created by itself? That it must always exist as a base class for some other class? All you have to do is make your class abstract. Then it can only be instantiated as part of another class that derives from your class. This episode will explain why you might want to do this and how.

Because one of the biggest reasons to use inheritance is so you can override a method and provide your own implementation, then it makes sense that a big reason for you to plan for inheritance is so that your methods can be overridden.

But what if your base class doesn’t have the ability to provide its own implementation. If you leave the method out, then it’s no longer part of the base class. You want it to be included in the base class so you can still make use of the virtual behavior. The solution is to make the method a pure virtual method and declare that there is no implementation at the base class level. This makes your base class abstract.

An abstract class cannot be instantiated, or created, on its own. It must always serve as the base class for one or more other classes. As soon as you have a derived class that fully implements all the pure virtual methods, then that derived class becomes concrete. That’s a class that can be created. When you create a concrete class, you end up creating any abstract classes just like any other base class.

Making a class abstract just ensures that it will never exist on its own and must always be part of another derived class. It also gives you the ability to declare methods at the base class level which will be guaranteed to be implemented by at least one of the derived classes.