17.1  Example - Operator Member Functions

The addition operator as a member function of the Time class:
class Time
{
   ...
   Time operator+( int sec ) const;
};

Time Time::operator+( int sec ) const
{
   Time r = *this;  // Copy the implicit parameter
   r.add_seconds( sec );
   return r;
}

prev |top |next