64,682
社区成员
发帖
与我相关
我的任务
分享
[
template<class _Ty = void>
struct greater
: public binary_function<_Ty, _Ty, bool>
{ // functor for operator>
bool operator()(const _Ty& _Left, const _Ty& _Right) const
{ // apply operator> to operands
return (_Left > _Right);
}
};
/code]
如果我传递一个Person对象 然后Person对象重载 > <运算符 这样可不可以?
[code=c]
class Person
{
public:
string name;
int age;
bool operator<(const Person& obj)
{
return (this->age < obj.age);
}
bool operator>(const Person& obj)
{
return (this->age > obj.age);
}
};