// StdCalls.cpp // tom bailey 6 oct 08 // Demonstrate calls to default and copy constructor, // destructor, and assignment operator. #include using std::cout; using std::endl; // A Verbose Simple class class Exam { public: Exam() { cout << "Exam default constructor called" << endl; } Exam( const Exam & exam ) { cout << "Exam copy constructor called" << endl; } ~Exam() { cout << "Exam destructor called" << endl; } const Exam & operator=( const Exam & exam ) { cout << "Exam assignment operator called" << endl; return *this; } Exam( double dbl ) { cout << "Exam( double ) constructor called" << endl; } }; int main() { cout << "a" << endl; Exam a; cout << "b" << endl; Exam b( 3.1 ); cout << "c" << endl; Exam c = b; cout << "d" << endl; Exam * d; cout << "e" << endl; Exam * e = new Exam( 0.0 ); cout << "d" << endl; d = e; cout << "f" << endl; Exam * f = new Exam( * d ); cout << "d" << endl; *d = *f; cout << "g" << endl; Exam g( a ); cout << "d" << endl; *d = g; cout << "h" << endl; Exam * h = d; cout << "i" << endl; Exam i( * d = c ); cout << "delete segment" << endl; delete d; delete f; cout << "end" << endl; return 0; }