Self-Review Exercises

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

    1. Class members are accessed via the            operator in conjunction with the name of an object (or reference to an object) of the class or via the            operator in conjunction with a pointer to an object of the class.

    2. Class members specified as            are accessible only to member functions of the class and friends of the class.

    3.            class members are accessible anywhere an object of the class is in scope.

    4.            can be used to assign an object of a class to another object of the same class.

    5. A nonmember function must be declared by the class as a(n)            of a class to have access to that class’s private data members.

    6. A constant object must be           ; it cannot be modified after it’s created.

    7. A(n)            data member represents classwide information.

    8. An object’s non-static member functions have access to a “self pointer” to the object called the            pointer.

    9. Keyword            specifies that an object or variable is not modifiable.

    10. If a member initializer is not provided for a member object of a class, the object's            is called.

    11. A member function should be static if it does not access            class members.

    12. Member objects are constructed            their enclosing class object.

    13. 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.

  2. 9.2 Find the error(s) in each of the following and explain how to correct it (them):

    1. Assume the following prototype is declared in class Time:

      
      void ~Time(int);
      
    2. Assume the following prototype is declared in class Employee:

      
      int Employee(string, string);
      
    3. The following is a definition of class Example:

      
      class Example {
      public:
         Example(int y = 10) : data(y) { }
         int getIncrementedData() const {
            return ++data;
         }
         static int getCount() {
            cout << "Data is " << data << endl;
            return count;
         }
      private:
         int data;
         static int count;
      };
      
..................Content has been hidden....................

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