单选题
将前缀运算符“——”重载为非成员函数,下列原型中,能正确用于类中说明的是( )。
A、
Decr& operator——(int);
B、
Decr operator——(Decr&, int);
C、
friend Decr& operator—— (Decr&);
D、
friend Decr operator——(Decr&,int);
【正确答案】
C
【答案解析】
解析:因为要作为非成员函数重载,所以加friend,作为前缀操作,其返回的操作结果是对该变量的引用,所以类型为Decr&,操作数出现在参数表中,应声明为引用,即Decr&。
提交答案
关闭