Question: Exercise #3 Given the following Program: class One { public: int one; One() { one = 1; } }; class Two :public One { public:
Exercise #3 Given the following Program: class One { public: int one; One() { one = 1; } }; class Two :public One { public: int two; Two() { this->two = 2; } }; void main() { Two* two = new Two(); cout << two->one << two->two; } What is the expected result of the execution ? a. Compilation Error . b. 12 c. 21 d. 22
Exercise #4 Given the following Program: class A { public: A(int x = 1) { this->x = x; } ~A() { cout << x; } int x; }; class B { public: B(int n = 3) { this->n = n; p = new A[n]; } ~B() { delete[] p; } int n; A* p; }; void main() { B* p = new B(); } What is the expected result of the execution ? a. 1 b. Compilation Error c. The program prints nothing since B was dynamically allocated and not release d. 3
Exercise #5 Given the following Program: template
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
