www.gibmonks.com

Main Page




Previous Page
Next Page

[Page 121 (continued)]

Self-Review Exercises

3.1

Fill in the blanks in each of the following:

  1. A house is to a blueprint as a(n) _________ is to a class.

  2. Every class definition contains keyword _________ followed immediately by the class's name.

  3. A class definition is typically stored in a file with the _________ filename extension.

  4. Each parameter in a function header should specify both a(n) _________ and a(n) _________.

  5. When each object of a class maintains its own copy of an attribute, the variable that represents the attribute is also known as a(n) _________.

  6. Keyword public is a(n) _________.

  7. Return type _________ indicates that a function will perform a task but will not return any information when it completes its task.

  8. Function _________ from the <string> library reads characters until a newline character is encountered, then copies those characters into the specified string.


  9. [Page 122]
  10. When a member function is defined outside the class definition, the function header must include the class name and the _________, followed by the function name to "tie" the member function to the class definition.

  11. The source-code file and any other files that use a class can include the class's header file via an _________ preprocessor directive.

3.2

State whether each of the following is true or false. If false, explain why.

  1. By convention, function names begin with a capital letter and all subsequent words in the name begin with a capital letter.

  2. Empty parentheses following a function name in a function prototype indicate that the function does not require any parameters to perform its task.

  3. Data members or member functions declared with access specifier private are accessible to member functions of the class in which they are declared.

  4. Variables declared in the body of a particular member function are known as data members and can be used in all member functions of the class.

  5. Every function's body is delimited by left and right braces ({ and }).

  6. Any source-code file that contains int main() can be used to execute a program.

  7. The types of arguments in a function call must match the types of the corresponding parameters in the function prototype's parameter list.

3.3

What is the difference between a local variable and a data member?

3.4

Explain the purpose of a function parameter. What is the difference between a parameter and an argument?


Previous Page
Next Page