|
|
By Alex, on January 30th, 2008
In the previous lesson on pointers and references to the base class of derived objects, we took a look at a number of examples where using pointers or references to a base class had the potential to simplify code. However, in every case, we ran up against the problem that the base pointer or . . . → Read More: 12.2 — Virtual functions
By Alex, on January 29th, 2008
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 first set the table . . . → Read More: 12.1 — Pointers and references to the base class of derived objects
By Alex, on January 28th, 2008
[ 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 Michael Bruinsma. Despite the . . . → Read More: Break Time — Saint Petersburg
By Alex, on January 28th, 2008
Note: This section is an advanced topic and can be skipped or skimmed if desired.
In the previous section on multiple inheritance, we left off talking about the “diamond problem”. In this section, we will resume this discussion.
Virtual base classes
Here is our example from the previous lesson, with some constructors:
class PoweredDevice . . . → Read More: 11.8 — Virtual base classes
By Alex, on January 24th, 2008
So far, all of the examples of inheritance we’ve presented have been single inheritance — that is, each inherited class has one and only one parent. However, C++ provides the ability to do multiple inheritance. Multiple inheritance enables a derived class to inherit members from more than one parent.
Let’s say we wanted to . . . → Read More: 11.7 — Multiple inheritance
|
|