b7_7.cxx

b7_7.cxx

#include ‹stream.hxx›

struct base { base(); };

struct derived: base { derived(); };

base:: base()

{

 cout ‹‹ " base 1: this=" ‹‹ long(this) ‹‹ " ";

 if (this == 0) this = (base*)27;

 cout ‹‹ " base 2: this=" ‹‹ long(this) ‹‹ " ";

}

derived::derived()

{

 cout ‹‹ " derived 1: this=" ‹‹ long(this) ‹‹ " ";

 if (this == 0) this = (derived*)43;

 cout ‹‹ " derived 2: this=" ‹‹ long(this) ‹‹ " ";

}

main()

{

 cout ‹‹ "base b; ";

 base b;

 cout ‹‹ "new base; ";

 new base;

 cout ‹‹ "derived d; ";

 derived d;

 cout ‹‹ "new derived; ";

 new derived;

 cout ‹‹ "new derived; ";

 new derived;

 cout ‹‹ "at the end ";

}