Problem

Suppose that you have the following classes, classA and classB :class classA{public :virtu...

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;}

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT