15. Two Complete OOP Examples

If you’ve stayed with me through the last three chapters—I call them “object-oriented boot camp”—then congratulations! I’ve taken you through a number of the subtleties of writing C++ classes, complete with constructors and operator functions.

But now it’s time to have some fun with classes! In this chapter, we’ll use classes to implement a customized linked list and to animate the Tower of Hanoi puzzle solution from Chapter 4.

Introducing Linked Lists

We’ve been able to use arrays to do quite a lot. With dynamic memory allocation, arrays can even be given a size determined at runtime. But there are still limitations: Once fixed, the length of an array can’t be changed without destroying the array and starting over. ...

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.