class Time
{
private:
int minutes;
public:
Time operator+(const Time & t);
friend Time operator*(double clock,const Time &time);
};
若 Time operator+(const Time & t)重载正确,那么 Time t1; auto time= 22+t1;是一个正确的使用。
friend Time operator*(double clock,const Time &time),这个函数可以访问Time类的minutes变量
friend Time operator*(double clock,const Time &time),这个函数是一个非成员函数
friend Time operator*(double clock,const Time &time),这个函数传入的参数可以是3个
"->"只能重载为类成员函数