使用友元函数为Stonewt类重载乘法运算符,该运算符将double值与Stone值相乘。
// prototype friend Stonewt operator*(double mult, const Stone & s); // definition - let constructor do the work Stonewt operator*(double mult, const Stonewt & s) { return Stonewt(mult * s.pounds); }
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题