Question: 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
Get step-by-step solutions from verified subject matter experts
