what is the differnece between the two coding styles

Hi all:
i just saw this,assuming var is a variable.
1
2
3
if(-1 != var){
        ;
}


another common coding style is
1
2
3
if(var != -1){
        ;
}


my question is any difference between the two regarding to efficiency,etc.

thanks in advance.
This is a good question I would like to know the answer though.

However C++ allow operator overloading so by swapping them around I am worried it may cause compiler or run-time error.

Usually for operator overloading, we assume the argument is rhs of the class unless we use friend function concept to explicitly cater for argument on the lhs also.
It is a reactive style used to help prevent errors like if (var = -1), which most compilers (until very recently, I believe) blithely accepted in good faith. (Many modern compilers will warn you that an assignment is probably not what you meant to write.)

A properly-overloaded operator will work with the operands on either side. There is no 'usually' other than that; you should have both the member and friend overloads.

Hope this helps.
@Duoas

according to what you said, i am glad to know that this prevents the most easy-making mistake in c/c++, in other hand, has this nothing to do with efficiency ?
has this nothing to do with efficiency ?

No, not at all.
Topic archived. No new replies allowed.