sort 排序 自定义排序算法的使用

// struct sort_by_pt
// {
// bool operator()(const std::pair<CString, AcGePoint3d> a, const std::pair<CString, AcGePoint3d> b)
// {
// return a.second.x < b.second.x;
// }
// };

// bool Compare_indexx(PtToText a, PtToText b)
// {
// double pta = a.ptx;
// double ptb = b.ptx;
// return pta.x<ptb.x;
// } 

 

std::sort(allText.begin(), allText.end(), [](const PtToText&a, const PtToText&b){return a.ptx<b.ptx; }); 

 

重载运算符

class test
{
public:
test();
~test();

private:
public:
int a;
struct qqq
{
int d;
double b;
};
qqq m_s;
int test::operator+(const test&b)
{
return a+ b.a;
}
int test::operator-(const test&b)
{
return a - b.a;
}
};

test::test()
{
}

test::~test()
{
}
int _tmain(int argc, _TCHAR* argv[])
{
test ds,da;
ds.a = 50;
da.a = 20;
int b = ds + da;
int c = ds - da;
cout << b << endl;
cout << c << endl;
return 0;
}

转载于:https://www.cnblogs.com/xzh1993/p/6702298.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值