< Previous | Contents | Next >

Exercises

1. Whats wrong with the following prototype?

int askNumber(int low = 1, int high);


2. Rewrite the Hangman game from Chapter 4 using functions. Include a function to get the players guess and another function to determine whether the players guess is in the secret word.

3. Using default arguments, write a function that asks the user for a number and returns that number. The function should accept a string prompt from the calling code. If the caller doesnt supply a string for the prompt, the function should use a generic prompt. Next, using function overloading, write a function that achieves the same results.



chapter 6


image