25.7 — Pure virtual functions, abstract base classes, and interface classes

Pure virtual (abstract) functions and abstract base classes So far, all of the virtual functions we have written have a body (a definition). However, C++ allows you to create a special kind of virtual function called a pure virtual function (or abstract function) that has no body at all! A …

25.6 — The virtual table

To implement virtual functions, C++ implementations typically use a form of late binding known as the virtual table. The virtual table is a lookup table of functions used to resolve function calls in a dynamic/late binding manner. The virtual table sometimes goes by other names, such as “vtable”, “virtual function …

25.4 — Virtual destructors, virtual assignment, and overriding virtualization

Virtual destructors Although C++ provides a default destructor for your classes if you do not provide one yourself, it is sometimes the case that you will want to provide your own destructor (particularly if the class needs to deallocate memory). You should always make your destructors virtual if you’re dealing …

25.1 — Pointers and references to the base class of derived objects

In the previous chapter, you learned all about how to use inheritance to derive new classes from existing classes. In this chapter, we are going to focus on one of the most important and powerful aspects of inheritance — virtual functions. But before we discuss what virtual functions are, let’s …

Break Time — Saint Petersburg

[ We’ve been having some funkiness going on with our caching plugin. If you went to http://www.learncpp.com and ended up here instead, please post a comment and let us know. Thanks! ] Saint Petersburg is a board game originally released in 2004 by Bernd Brunnhofer, Michael Tummelhofer, Jay Tummelson, and …