< previous page page_898 next page >

Page 898
4. If you do not use the reserved words public and private, all members of a C++ class are private and all members of a struct are public. (True or False?)
5. Define the following terms:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
instantiate
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
const member function
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
specification file
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
implementation file
6. To the TimeType class we wish to add three observer operations: CurrentHrs, CurrentMins, and CurrentSecs. These operations simply return the current values of the private data to the client. We can amend the class declaration by inserting the following function prototypes into the public part:
int CurrentHrs() const;
    // Postcondition:
    //     Function value == hours part of the time of day

int CurrentMins() const;
    // Postcondition:
    //     Function value == minutes part of the time of day

int CurrentSecs() const;
    // Postcondition:
    //     Function value == seconds part of the time of day
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Write the function definitions for these three functions as they would appear in the implementation file.
7. Classify each of the seven member functions of the TimeType class (pages 866867) as a constructor, a transformer, or an observer operation.
8. Answer the following questions about Figure 15-6, which illustrates the process of compiling and linking a multifile program.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. If only the file myprog.cpp is modified, which files must be recompiled?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. If only the file myprog.cpp is modified, which files must be relinked?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. If only the files file2.cpp and file3.cpp are modified, which files must be recompiled? (Assume that the modifications do not affect existing code in myprog.cpp.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
d. If only the files file2.cpp and file3.cpp are modified, which files must be relinked? (Assume that the modifications do not affect existing code in myprog.cpp.)
9. Define the following terms:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
scope resolution operator
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
separate compilation
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
C++ class constructor
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
default constructor
10. The following class has two constructors among its public member functions:

 
< previous page page_898 next page >