Suppose that you have the following classes, classA and classB :
class classA{public :virtual void print ( ) const;void doubleNum ( );classA(int a = 0);private:int x;};void classA::print ( ) const{cout ≪ "ClassA x: " ≪ x ≪ end1;}void classA::doubleNum ( ){x = 2 * x;}classA::classA(int a){x = a;}class classB: public classA {public:void print ( ) const;void doubleNum ( );classB(int a = 0, int b = 0);private:int y;};void classB::print ( ) const {classA::print ( );cout ≪ “ClassB y: ” ≪ y ≪ end1;void classB::doubleNum(){classA::doubleNum(); y = 2 * y;}classB::classB(int a, int b): classA(a){y = b;}What is the output of the following function main ? int main ( )
{classA *ptrA;classA objectA(2);classB objectB(3, 5);ptrA = &objectA;ptrA- > doubleNum ( );ptrA- > print ( );cout ≪ endl;ptrA = &objectB;ptrA->doubleNum ( );ptrA->print ( );cout ≪ endl;return 0;}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.