重载运算符
该函数为友元函数 不然是 time<<cout
ostream & operator<<(ostream & os,const Time &t)
{
os<<XX<<' '<<YY;
return os;
}
在这里 return os是为了可以连贯的cout
(cout<<1)<<Time;
重载运算符 = () [] -> 这四个运算符 只能作为成员函数而不能作为友元函数
Complex operator ++();//前缀自增
Complex operator ++(int);//后缀自增,参数需要加int

浙公网安备 33010602011771号