// A1.4.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; class X { public: X() { cout << "\n in X::X()"; } ~X() { cout << "\n in X::~X()"; } }; class Y { public: // main won't compile if any of these constructors are not defined Y() { cout << "\n in Y::Y()"; } Y(const X& x) /* : nothing to initialize */ { cout << "\n in Y::Y(const X& x)"; } Y(const Y& y) /* : nothing to initialize */ { cout << "\n in Y::Y(const Y& y)"; } ~Y() { cout << "\n in Y::~Y()"; } }; int _tmain(int argc, _TCHAR* argv[]) { std::cout << "\n Exam A1 - Question #4 " << "\n =======================\n"; cout << "\n\n-- first statement --"; X x1, x2; cout << "\n\n-- second statement --"; Y y2 = x1; cout << "\n\n-- third statement --"; Y y[4] = { x1, x2, X() }; return 0; }