There are four classes A, B, C and D. They all have the same form as follows:
class X
{
public:
X() { cout << "In X()" << endl; }
~X() { cout << "In ~X()" << endl; }
};
X belongs to{ A, B, C, D }. These four classes have some kind of inheritance relationship. You are to find the right one to generate the desired output, which should come from the constructors and destructors.
Your submitted source code should include all the implementationof the A, B, C and D classes.
No main() functionshouldbeincluded.
Note: the main() functionofthetestframeworklookslikethis:
------------------------------------------------------------------------------
int main()
{
D d;
return 0;
}
------------------------------------------------------------------------------
Input
Output
In B()
In C()
In B()
In A()
In D()
In ~D()
In ~A()
In ~B()
In ~C()
In ~B()
usingnamespacestd;
class B{
public:
B() { cout << "In B()" << endl; }
~B() { cout << "In ~B()" << endl;}
};
class A:public B
{
public:
A() { cout << "In A()" << endl; }
~A() { cout << "In ~A()" << endl;}
};
class C:public B
{
public:
C() { cout << "In C()" << endl; }
~C() { cout << "In ~C()" << endl;}
};
class D:public C,public A{
public:
D() { cout << "In D()" << endl; }
~D() { cout << "In ~D()" << endl;}
};
There are four classes A, B, C and D. They all have the same form as follows: class X{public: X() { cout &amp;lt;&amp;lt; &quot;In X()&quot; &amp;lt;&amp;lt; endl; } ~X() { cout &amp;lt;&amp;lt; &quot;In ~X()