Why << need to be friend? You need to consider: Because you need to
write cout<< obj. If you declare << as a member operator, you have to
write obj<<cout; it looks weird.
If you want to overload + operator, and support time t; 3+t; Previous
method can’t be work. You need to define a friend function. In order to
improve a t+3 efficiency, you also can define a member function time
operator+(int i) member function.
ob = ob1+ob2 will changed to: ob1.operator+(ob2); so, it should be
defined as the first const to avoid ob1+obj2= ob3, the last const
make the ob to invoke this operator doesn’t change the value in this
class.
assignment operator overload. 1) return a non-const reference, and 2) to
avoid assign self.