MCQs > IT & Programming > C++ > Consider the following code: #include using namespace std; class A { public: A() { cout << 'Constructor of A\n'; }; ~A() { cout << 'Destructor of A\n'; }; }; class B { public: B() { cout << 'Constructor of B\n'; }; ~B() { cout << 'Destructor of B\n'; }; }; class C { public: A objA; B objB; }; int main() { C *pC; pC = new C(); delete pC; return 0; } What will be the printed output?

C++ MCQs

Consider the following code:
#include<iostream>
using namespace std;
class A
{
public:
A()
{
cout << "Constructor of A\n";
};
~A()
{
cout << "Destructor of A\n";
};
};
class B
{
public:
B()
{
cout << "Constructor of B\n";
};
~B()
{
cout << "Destructor of B\n";
};
};
class C
{
public:
A objA;
B objB;
};
int main()
{
C *pC;
pC = new C();
delete pC;
return 0;
}
What will be the printed output?

Answer

Correct Answer: Constructor of A Constructor of B Destructor of B Destructor of A

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it