Question: Please help with explanations...thank you. Problem. Read the following C++ program, and determine its output. 1 #include 2 using namespace std ; 3 4 class

Please help with explanations...thank you.

Problem. Read the following C++ program, and determine its output. 1 #include

2 using namespace std ; 3

4 class Myst {

5 public :

6 unsigned compute( void ) ;

7 void setVal( unsigned n ) { cur_n = n ; }

8 private :

9 unsigned cur_n ;

10 };

11

12 int main( int argc , char argv ) {

13 Myst myOper ;

14 myOper . setVal( 7 ) ;

15 cout << myOper . compute () << endl ;

16 return 0;

17 }

18

19 unsigned Myst : : compute( void ) {

20 i f ( cur_n<=1 )

21 return 1;

else {

23 cur_n;

24 return (cur_n+1)compute () ;

25 }

26 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!