Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with explanations...thank you. Problem. Read the C++ code below, and answer the questions. 1 #include 2 using namespace std ; 3 4 class

Please help with explanations...thank you.

Problem. Read the C++ code below, and answer the questions. 1 #include

2 using namespace std ;

3

4 class BaseOp {

5 public :

6 virtual void increase( int ) = 0;

7 virtual void decrease( int ) = 0; 8 int getVal( void ) { return value ; }

9 BaseOp( void ) { value = 0; }

10 protected :

11 int value ;

12 };

13

14 class IncCube : public virtual BaseOp {

15 public :

16 void increase( int n ) {

17 value = value + n n n ;

18 }

19 IncCube( void ) { value = value + 5; }

20 };

21

22 class DecSquare : public virtual BaseOp {

23 public :

24 void decrease( int n ) {

25 value = value n n ;

26 }

27 DecSquare( void ) { value = value + 5; }

28 };

29

30 class MyOp : public IncCube , public DecSquare {

31 public :

32 MyOp( void ) { value = value + 5; }

33 };

34

35 int main( int argc , char argv ) {

36 MyOp myoper ;

37 myoper . increase( 13 ) ;

38 myoper . decrease( 14 ) ;

39 cout << myoper . getVal () << endl ;

40 return 0;

41 }

(a). For the four classes weve dened, how many of them can be instantatiated? List all that can be done.

(b). Whats the nal output of the preceding program?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

Students also viewed these Databases questions