重载Point

重载Point

其中减法表示向量,乘法表示叉积

struct Point
{
    double x,y;
    friend double operator*(const Point A,const Point B)
    {
        return A.x*B.y-A.y*B.x;
    }
    friend Point operator-(const Point A,const Point B)
    {
        return {A.x-B.x,A.y-B.y};
    }
};
View Code

 

posted @ 2015-04-02 18:25  __560  阅读(192)  评论(0编辑  收藏  举报