如题,我想在结构体poi里定义函数sum并以此重载运算符,但是编译失败,代码如下
int X; struct poi { int k; int y; int sum(poi p3) { return -p3.k*X+p3.y; } friend bool operator<(const poi &p1,const node&p2) { return sum(p1)<sum(p2); } };
怎么写是对的?