C++之objectarx 自定义类型key,重载操作符
.h文件
#pragma once
#include
#include
typedef struct test_map {
void test(void);
test_map(AcGePoint3d sa)
{
_sa = sa;
//_sb = sb;
}
#if 1
bool operator < (const test_map & test1) const
{
return _sa.x < test1._sa.x;
}
#endif
#if 0
bool operator == (const test_map & test1) const
{
return _sa.x == test1._sa.x;
}
#endif
//private:
AcGePoint3d _sa;
//AcGePoint3d _sb;
}t_m;
#if 0
template
struct Compare
{
int operator()(const T& x, const T& k) const {
if (x._sa >= k._sa) return 0;
else return 1;
}
};
#endif
main。cpp
std::map
t_m ts1(AcGePoint3d(4,0,0));
test.insert(std::make_pair(ts1, _T("dada")));
CString str = test[AcGePoint3d(4, 0, 0)];