Original Post
Hi all: The code is as follows: And when I multiply a float float on the left hand side, like following, it doesn't work. But it works like: Could anyone tell me why this happens please? And how can I overload the operator properly so both left and right handside can work? Thanks
[source lang='cpp']
class My_Class{
public:
....
inline My_Class operator*(float d){
....;
}
....
}
int main(){
My_Class x;
float d;
My_Class y = d * x;
}
int main(){
My_Class x;
float d;
My_Class y = x * d;
}