C++ 重载运算符

struct point
{
    double x, y;
    point(double _x, double _y):x(_x), y(_y){}
    
    // 点-点=向量
    point operator-(const point &v){
        return point(x-v.x, y-v.y);
    }
    
    int dcmp(double x)const{
        if (fabs(x)<eps) return 0;
        else return x<0?-1:1;
    }
    bool operator == (const point &v)const{
        return (dcmp(x-v.x)==0 && dcmp(y-v.y)==0); 
    }
};
东北日出西边雨 道是无情却有情
原文地址:https://www.cnblogs.com/ccut-ry/p/8981183.html