2002

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                        FILE: september.cpp */
/*                                                                            */
/*  Shows the order of constructor and destructor calls                       */
/*  ===================================================                       */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.00   29-SEP-2002   P. Tellenbach   http://www.heimetli.ch/             */
/*                                                                            */
/******************************************************************************/

#include <iostream>

using namespace std ;

class Base
{
 public:
   Base()   { cout << "He" ; }
  ~Base()   { cout << "!\n"; }
} ;

class Member
{
 public:
   Member() { cout << "ll" ; }
  ~Member() { cout << "d " ; }
} ;

class Derived : public Base
{
 protected:
   Member member ;

 public:
   Derived()      { cout << "o w" ; }
  ~Derived()      { cout << "orl" ; }
  int operator*() { return 0 ;      }
} ;

int main()
{
  return *Derived() ;
}