Question #246959

2. In Q1, add default as well as parameterized constructors in both base & derived class. Create object of Alarm_Clock class. Make it to call parameterized constructors of base as well as derived. Add destructors also. Check the order of destructors when derived class object goes out of scope.

Expert's answer

#include <iostream>
using namespace std;
class Base
{
   int m;


public:
   Base()
   {
      cout << "Default constructor in base\n";
   }
};


class Derived : public Base
{
   int n;


public:
   Derived()
   {
      cout << "Default constructor derived\n";
   }
   Derived(int i)
   {
      cout << "Parameterized constructor derived\n";
   }
};
class Alarm{
	public:
		~Alarm();//destructor
};
int main()
{
   Base z;
   Derived x1;
   Derived x2(4);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS