
126 Chapter 7
Program 83: Wild Output
A student of C++ wanted to see how constructors and destructors were called, so
he wrote the following program. Yet he learned more than he bargained for.
What’s the problem?
1 /************************************************
2 * Class tester. Test constructor / destructor*
3 * calling. *
4 ************************************************/
5 #include <iostream>
6
7 /************************************************
8 * tester -- Class that tells the world when *
9 * it's created and destroyed. *
10 ************************************************/
11 class tester {
12 public:
13 tester(void) {
14 std::cout <<
15 "tester::t ...