17. Inheritance: What a Legacy
Inheritance (also called subclassing, or deriving a class) was once the most heavily promoted idea in object orientation. It promised to save a lot of work.
These days, it is more controversial; programmers debate how often to use it. Near the end of the chapter, I’ll show it in the context of a carefully thought-out inheritance tree...but those take a lot of work to build an example around.
For now, we’ll look at simple uses of inheritance—including new features of C++0x that make it easier to use—and consider its more sophisticated uses later.
How to Subclass
One of the themes of this book is reusable code. If a problem is solved once, you don’t want to solve it again. So if a class does a particular job, you ...
Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.