/////////////////////////////////////////////////////////////////// // operations.cpp - illustrates operations for code question #8 // // Exam2:Q8 // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 05 // /////////////////////////////////////////////////////////////////// #include class Y { public: Y() { std::cout << "\n Y() called"; } Y(const Y& y) { std::cout << "\n Y(const Y&) called"; } ~Y() { std::cout << "\n ~Y() called"; } Y& operator=(const Y& y) { std::cout << "\n Y::assignment never called"; return *this; } }; class X : public Y { public: X() : Y() { std::cout << "\n X() called"; } X(const X& x) : Y(x) { std::cout << "\n X(const X&) called"; } X(double d) : Y() { std::cout << "\n X(double) called"; } ~X() { std::cout << "\n ~X() called"; } X& operator=(const X& x) { std::cout << "\n X::assignment never called"; return *this; } }; void main() { std::cout << "\n First Statement"; X x1; std::cout << "\n Second Statement"; X x[4] = { 1, X(), x1 }; std::cout << "\n after Second Statement"; };