-
Modify the
Tv
andRemote
classes as follows:a. Make them mutual friends.
b. Add a state variable member to the
Remote
class that describes whether the remote control is in normal or interactive mode.c. Add a
Remote
method that displays the mode.d. Provide the
Tv
class with a method for toggling the newRemote
member.
This method should work only if the TV is in the on state.Write a short program that tests these new features.
-
Modify Listing 15.11 so that the two exception types are classes derived from the
logic_error
class provided by the<stdexcept>
header file. Have eachwhat()
method report the function name and the nature of the problem. The exception objects need not hold the bad values; they should just support thewhat()
method. -
This exercise is the same as Programming Exercise 2, except that the exceptions should be derived from a base class (itself derived from
logic_error
) that stores the two argument values, the exceptions should have a method that reports these values as well as the function name, and a singlecatch
block that catches the base-class exemption should be used for both exceptions, with either exception causing the loop to terminate. -
Listing 15.16 uses two catch blocks after each try block so that the
nbad_index
exception leads to thelabel_val()
method being invoked. Modify the program so that it uses a single catch block after eachtry
block and uses RTTI to handle invokinglabel_val()
only when appropriate.
chapter15
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||