如何编写全局非成员 post 递减重载运算符?
How a write a global non member post decremented overloaded operator?
我开始编程了。我卡在了这一点上,所以我希望你们能帮助我。
当我们编写一个 post 递减成员函数时,语法是
type type::operator--(int){}
但是我想把它作为一个友元函数,我该怎么写呢?
这是预增量:
friend Mystring &operator--( Mystring &lhs);
post 递增的语法是什么?
这样试试:
class type
{
// ...
// postfix operator--
friend type operator--(type &t, int){type t1; /* some logics */ return t1;}
};
我开始编程了。我卡在了这一点上,所以我希望你们能帮助我。
当我们编写一个 post 递减成员函数时,语法是
type type::operator--(int){}
但是我想把它作为一个友元函数,我该怎么写呢?
这是预增量:
friend Mystring &operator--( Mystring &lhs);
post 递增的语法是什么?
这样试试:
class type
{
// ...
// postfix operator--
friend type operator--(type &t, int){type t1; /* some logics */ return t1;}
};