< previous page page_a77 next page >

Page A77
Chapter 18
Case Study Follow-Up
1. a. The functions Length, CardAt, InsertTop, RemoveTop, Shuffle, Recreate, and the class constructor are public members of the CardDeck class.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. The variables head and listLength and the function Merge are private members of the CardDeck class.
Chapter 19
Exam Preparation Exercises
2. False. Both void functions and value-returning functions can be recursive.
4.F(4) = 1, F(6) = -1, and F(5) is undefined.
6. A selection control structureeither an If or a Switch statement
9. The run-time stack
Chapter 19
Programming Warm-Up Exercises
1. int F( /* in */ int n )
   {
       if (n == 0 | | n == 1)
           return 1;
       else
       return F(n - 1) + F(n - 2);
   }

3. void DoubleSpace( /* inout */ ifstream& inFile )
   {
       char ch;

       inFile.get(ch);
       while (inFile)           // While not EOF
       {
           cout << ch;
           if (ch == \n)
               cout << endl;
           inFile.get(ch);
       }
   }
8. In the If statement of the RevPrint function, change the sequence
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
RevPrint(head->link);             // Recursive call
cout << head-component << endl;

 
< previous page page_a77 next page >