ex4-2.cpp - Example 4-2 Constructor/Destructor - scope

// File:  ex4-2.cpp

#include <iostream>
using namespace std;

class test
{
  private:
	 char ch;
  public:
	 test(char);  // constructor
	 ~test();     // destructor
};

test::test(char c)
{
  ch = c;
  cout << "*** constructor called for object " << ch << endl;
}

test::~test()
{
  cout << "destructor called for object " << ch << endl;
}

int main(void)
{
  test a('a');
  {
	 test b('b');
  }
  {
	 test c('c');
	 {
		test d('d');
	 }
  }
  return 0;
}



CIS27: Programming in C++    Instructor: Joe Bentley