J
Jess
Hello,
After seeing some examples about operator overloading, I'm still a bit
confused about the general syntax. The following is what I think, not
sure whether it's correct.
1. For a unary operator that's a member of a class, its form is
usually
"operatorP()" (where P is the operator's name).
If it's a non-member operator, then its form is
"operatorP(arg)"
2.For a binary operator that's a member of a class, its form is:
operatorP(arg),
where arg is the right argument of P.
If it's a non-member operator, then its form is
"operatorP(argLeft,argRight)"
Is there anything I've missed? Moreover, can I overload a ternary
operator? I think there's only one ternary operator, which is "a ?
b:c".
Many thanks,
Jess
After seeing some examples about operator overloading, I'm still a bit
confused about the general syntax. The following is what I think, not
sure whether it's correct.
1. For a unary operator that's a member of a class, its form is
usually
"operatorP()" (where P is the operator's name).
If it's a non-member operator, then its form is
"operatorP(arg)"
2.For a binary operator that's a member of a class, its form is:
operatorP(arg),
where arg is the right argument of P.
If it's a non-member operator, then its form is
"operatorP(argLeft,argRight)"
Is there anything I've missed? Moreover, can I overload a ternary
operator? I think there's only one ternary operator, which is "a ?
b:c".
Many thanks,
Jess