首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为什么这样自定义操作符不行,该如何解决

2012-03-09 
为什么这样自定义操作符不行structCCC{intiintj}structABC{booloperator(constCCC&a1,constCCC&a2){re

为什么这样自定义操作符不行
struct   CCC
{
    int   i;
    int   j;
};
struct   ABC
{
    bool   operator   <(const   CCC&   a1,   const   CCC&   a2)   {return   a1.i   <   a2.i;}
};
我想把这个ABC传给sort,编译无法通过
能说下原因吗

[解决办法]
struct ABC
{
bool operator ()(const CCC& a1, const CCC& a2) {return a1.i < a2.i;}
};

热点排行