Originally Posted by
polonyman
but it doesn't output dog destructor called once
This is the output I get:
Code:
nyda, nyda/ $ ./test
Dog Constructor Called
Dog Constructor Called
Rover is 0 years old.
He weighs 0 lbs.
Updating Rover's Age and Weight
Rover is 1 years old.
He weighs 10 lbs.
Fido is 0 years old.
He weighs 0 lbs.
Setting Fido to be the same as Rover
Fido is 1 years old.
He weighs 10 lbs.
BARK!!
BARK!!
Dog Destructor Called
Dog Destructor Called
That is with gcc (GCC) 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6), which should produce about the same code GCC/MinGW does.
The destructors should be called in any case, no matter what you do with the objects references.