// File: constructors.cpp // // A quick and dirty program to check // which constructors are called. // // Exercise: how many CMSC202 Coding Standards // is violated in this file? #include using namespace std ; class abc { public: abc() { cout << "Default Constructor called\n" ; // m = 17 ; abc(42) ; } abc(int i ) { cout << "Alternate Constructor called\n" ; m = i ; } abc(const abc& y) { cout << "Copy Constructor called\n" ; m = y.m ; } abc& operator =(const abc& rhs) { cout << "Assignment operator called\n" ; if ( this != &rhs) { // if not self assignment m = rhs.m ; return *this ; } return *this ; } int m ; } ; int main() { //const abc x = abc(4) ; // const abc x ; abc x ; //abc y(17) ; //abc y = abc(17) ; // abc array[26] ; //y = abc(17) ; //x = abc(40) ; cout << x.m << endl ; }