Sams Teach Yourself C++ in 21 Days

(singke) #1
Special Classes and Functions 535

15



  1. Using the program from Exercise 1, write a short driver program that makes three
    objects and then displays their member variables and the static member variable.
    Then destroy each object and show the effect on the static member variable.

  2. Modify the program from Exercise 2 to use a static member function to access the
    static member variable. Make the static member variable private.

  3. Write a pointer to member function to access the nonstatic member data in the pro-
    gram in Exercise 3, and use that pointer to print the value of that data.

  4. Add two more member variables to the class from the previous exercises. Add
    accessor functions that get the value of this data and give all the member functions
    the same return values and signatures. Use the pointer to member function to
    access these functions.

Free download pdf