// 2002/07/05 // AWZZZ
// Study observation of C intentional structural pattern function call phenomenon
// Phenomenon // Call the overloaded constructor B // conclusions in the constructor A. The destructor has been called when the B is called end (A until end).
// Follow
// Test platform // 1.win2k vc6 // 2.Linux GCC
/ * // Program run output CTEST (0, 0) ~ ctest () m_ctestcount = 1ctest (0) ~ ctest () m_ctestcount = 2ctest () main () ~ ctest () m_ctestcount = 3 // Program run output * /
#include
Class ctest {public: ctest () {ctest (0);
/ / The destructor has been called
Printf ("ctest () / r / n");} Virtual ~ ctest () {m_ctestcount ; Printf ("~ ctest () m_ctestcount =% d / r / n", m_ctestcount);} ctest (int i) {ctest (i, 0);
/ / The destructor has been called
Printf ("CTEST (% D) / R / N", I);} CTEST (INT I, INT J) {Printf ("CTEST (% D,% D) / R / N", I, J);} Static int m_ctestcount;};
INT ctest :: m_ctestcount = 0;
Int main () {ctest CT;
Printf ("" main () / r / n ");
// Call the destructor
Return 0;}