当前位置:首页 > 编程笔记 > 正文
已解决

结构体运算符重载

来自网友在路上 170870提问 提问时间:2023-10-02 08:26:17阅读次数: 70

最佳答案 问答题库708位专家为你答疑解惑

1.降序

struct Point{int x, y;//重载比较符bool operator < (const Point &a) const{return x > a.x;//当前元素大时,是降序}
};

在这里插入图片描述

2.升序

struct Point{int x, y;//重载比较符
//    bool operator < (const Point &a) const{
//        return x > a.x;//当前元素大,降序
//    }bool operator < (const Point &a) const{return x < a.x;//当前元素小,升序}
};

在这里插入图片描述

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"结构体运算符重载":http://eshow365.cn/6-15776-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!