a simple example destructor,i really donot understand the output
the output is like this:Code:#include<iostream> using namespace std; class T { public: T( double d ) : pd( new double( d ) ) { }; ~T(); private: double *pd; }; T::~T() { cout << ( *pd ) << endl; // ( *pd ) = -1; // delete pd; } extern void func( T t ) { /* ... */ cout << " Here " << endl; } void main() { T t( 1.2 ); T t1( 1.8 ); func( t ); func( t1 ); }
Here
1.2
Here
1.8
1.8
1.2
but in my opinion,it should be
Here
1.8
Here
1.2
so why? Could anyone explain it to me?
any help is appreciated...



LinkBack URL
About LinkBacks



CornedBee