Self-Review Exercises

  1. 3.1 Fill in the blanks in each of the following:

    1. Every class definition contains the keyword            followed immediately by the class’s name.

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

    3. Each parameter in a function header specifies both a(n)            and a(n)           .

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

    5. Keyword public is a(n)           .

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

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

    8. Any file that uses a class can include the class’s header via a(n)            preprocessing directive.

  2. 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 definition 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’re 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. The types of arguments in a function call must be consistent with the types of the corresponding parameters in the function’s parameter list.

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

  4. 3.4 Explain the purpose of a function parameter. What’s the difference between a parameter and an argument?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset