Exercise 7.5 & 7.6 are worded thus:
Quote:
5. Write a class called CTrace that you can use to show you at run time when code blocks have been entered and exited, by producing output like this:
Code:
function ‘f1’ entry
‘if’ block entry
‘if’ block exit
function ‘f1’ exit
6. Can you think of a way to automatically control the indentation in the last exercise, so that the output looks like this?
Code:
function ‘f1’ entry
‘if’ block entry
‘if’ block exit
function ‘f1’ exit
|
Having had plenty of experience with C++/C#, my first instinct would be to use destructors. However, destructors aren't covered in the book until Chapter 8. To satisfy my curiosity, I checked the solutions in the companion code for the book, and it indeed uses destructors.