首页 > 试题广场 >

看下面代码,关于运算符重载说法正确的有?class Time

[不定项选择题]
看下面代码,关于运算符重载说法正确的有?
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个
  • "->"只能重载为类成员函数
= ,-> ,[],()只能重载为类成员
发表于 2022-05-22 14:12:55 回复(2)
->只能重载为成员函数。
发表于 2021-09-25 17:01:33 回复(1)