C++ 运算符重载顺序

Nam*_*Ngo 2 c++ overriding operator-keyword

可能的重复:
C++ 中的运算符重载为 int + obj

我重写 * 运算符如下:

Point Point::operator *(float scale){
    Point point(this->x*scale, this->y*scale);
    return point;
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题:

Point p1 (5.0, 10.0);
Point p2 = p1*4; //works fine
Point p3 = 4*p1  //error: no match for 'operator*' 
Run Code Online (Sandbox Code Playgroud)

Ben*_*ley 5

编写一个自由函数,如下所示:

Point operator *(float scale, Point p)
{
    return p * scale;
}
Run Code Online (Sandbox Code Playgroud)