// File: meminit2.cpp // // Comparing the difference between // using assignment and member initializers. // #include #include "dmc2.h" using namespace std ; class AClass { public: AClass() { cout << "Creating AClass object\n" ; } AClass(const DMC& Y, int n) : X(Y), stuff(n) // member initializers { /* do nothing */ } ~AClass() { cout << "Destroying AClass object\n" ; } void Set(int n) { X.Set(n) ; } void Print() { cout << "stuff=" << stuff << ":" << X ; } private: DMC X ; int stuff ; } ; int main() { DMC Y ; Y.Set(11) ; cout << "Y=" << Y << endl ; AClass B(Y,17) ; cout << "B = " ; B.Print() ; cout << endl ; }