例如:
class Time
{
friend Time operator*(double m, const Time &t);
}
Time operator*(double m, const Time &t)
{
Time result;
long tota_min = t.hours * mult * 60 + t.minutes * mult;
result.hours = tota_min / 60;
result.minutes = tota_min % 60;
return result;
}
这样就可以实现 A = 2.75 * B;