Like so:
MyClass operator* (float x, const MyClass& y)
{
//...
}
MyClass operator* (const MyClass& y, float x)
{
//...
}
The second one can also be a member function:
class MyClass
{
//...
MyClass operator* (float x);
};
The first 2 options work as declarations outside of class scope.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…