typedef struct
{
int hours;
} Time;
Time addTime(Time time1, Time time2)
{
Time time;
time = time1.hours + time2.hours;
return time;
}
如果我想将时间作为结构返回怎么办?我试过这种方式,但我得到了很多错误。
error: no match for 'operator=' in 'time = (time1.Time::hours + time2.Time::hours)'
note: Time& Time::operator=(const Time&)
no known conversion for argument 1 from 'int' to 'const Time&'