Class encapsulation problem

Hi ! I'm having some trouble understanding class encapsulation on the following example (I don't think the rest of the source is relevant) . So I have a trivial Time class (from a C++ book) with two integers (minutes and hours) as private and all the member functions public .

Time Time::Sum(const Time & t) const
{
Time sum;
sum.minutes = minutes + t.minutes;
sum.hours = hours + t.hours + sum.minutes / 60;
sum.minutes %= 60;
return sum;
}


Why is it possible for an object to access other object's private members ? Thank you .
Private members are accessible within the class and its friends
Since an object is part of the class, it can access them
Topic archived. No new replies allowed.