O'Reilly logo

C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Second Edition by Brian Overland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required