Binary operator

B

Binary

Hi,

If there is operator overloading in both side of the binary operator,
such as: a < b.

Will the a's operator function be called or b?

Thanks.
ABAI
 
D

dasjotre

Binary said:
Hi,

If there is operator overloading in both side of the binary operator,
such as: a < b.

Will the a's operator function be called or b?
why not try?
 
R

Ron Natalie

Binary said:
Hi,

If there is operator overloading in both side of the binary operator,
such as: a < b.
Depends on what the operators are. It's possible that there are
no overloads for < that match, a unique best overload (which is the
one that is called), or multiple equally good ones which would be
an error due to the ambiguity.

You need to know what operator < overloads are available and whether
the types of a and b can be converted to what these < operators take.
 
?

=?ISO-8859-15?Q?Juli=E1n?= Albo

Binary said:
If there is operator overloading in both side of the binary operator,
such as: a < b.
Will the a's operator function be called or b?

Write (or imagine you write) the code as: operator < (a, b)

Then imagine that "operator <" is "somefunctionname"

Then use your knowledge about overloading resolution for functions to
resolve somefunctioname.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top