previous | start | next

## Calling Base-Class Member Functions

- A member function called without a parameter is called through the implicit parameter object of the derived class.

  >     if (is_military())  /* clock uses military time */
  >        return (h + time_difference) % 24;

- When the base class and the derived class have a member function with the same name, you must be more specific which function you want to call.

  >     int TrvaelClock::get_hours() const
  >     {
  >        int h = Clock::get_hours(); /* calls base-class function */
  >        . . .
  >     }

- The following call would die in an infinite recursion.

  >     int TravelClock::get_hours() const
  >     {
  >        int h = get_hours(); /* calls itself */
  >        . . .
  >     }

previous | start | next