12. Two Complete OOP Examples
In the last two chapters, I laid out the basic syntax of class and object declarations. Now we’re ready to apply object-oriented principles to programs that do something fun and useful.
First, I’ll explore a Binary Tree example, which is one of the more intriguing and challenging topics in programming, and then I’ll return to the Tower of Hanoi puzzle from Chapter 5, “Function: Many Are Called.” The new version of the program uses character-based animation to show the puzzle solution in action.
But first, a few more preliminaries....
Dynamic Object Creation
Pointers have yet another use: constructing networks of objects. This is called dynamic memory allocation because it requests memory at run time, letting the ...
Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Third 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.