|
|
|
|
|
|
|
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: |
|
|
|
 |
|
|
|
|
instantiate |
|
|
|
 |
|
|
|
|
const member function |
|
|
|
 |
|
|
|
|
specification file |
|
|
|
 |
|
|
|
|
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 |
|
|
|
 |
|
|
|
|
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. |
|
|
|
 |
|
|
|
|
a. If only the file myprog.cpp is modified, which files must be recompiled? |
|
|
|
 |
|
|
|
|
b. If only the file myprog.cpp is modified, which files must be relinked? |
|
|
|
 |
|
|
|
|
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.) |
|
|
|
 |
|
|
|
|
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: |
|
|
|
 |
|
|
|
|
scope resolution operator |
|
|
|
 |
|
|
|
|
separate compilation |
|
|
|
 |
|
|
|
|
C++ class constructor |
|
|
|
 |
|
|
|
|
default constructor |
|
|
|
|
|
|
|
|
10. The following class has two constructors among its public member functions: |
|
|
|
|
|