previous | start | next

## Accessing Data Fields

- Not every data member needs accessor functions (the `Product` class did not have a `get_score()` function).
- Not every `get_` function needs a matching `set_` (the `Time` class can `get_minutes()` but not `set_minutes()`).
- Remember that implementation is supposed to be hidden - just because a class has member functions named `get_` or `set_` does not necessarily explain how the class is designed.

  >     Time::Time(int hour, int min, int sec)
  >     {
  >        time_in_secs = 60 * 60 * hour + 60 * min + sec;
  >     }

  >     int Time::get_minutes() const
  >     {
  >        return (time_in_secs / 60) % 60;
  >     }

  >     int Time::seconds_from(Time t) const
  >     {
  >        return time_in_secs - t.time_in_secs;
  >     }

previous | start | next