Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Binary operator

Reply
Thread Tools

Binary operator

 
 
Binary
Guest
Posts: n/a
 
      10-24-2006
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

 
Reply With Quote
 
 
 
 
dasjotre
Guest
Posts: n/a
 
      10-24-2006

Binary wrote:
> 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?

 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      10-24-2006
Binary wrote:
> 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.
 
Reply With Quote
 
=?ISO-8859-15?Q?Juli=E1n?= Albo
Guest
Posts: n/a
 
      10-24-2006
Binary wrote:

> 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.

--
Salu2
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
x86 binary runs; x86_64 binary throws segfault Don C Programming 60 03-19-2010 05:58 AM
(8-bit binary to two digit bcd) or (8-bit binary to two digit seven segment) Fangs VHDL 3 10-26-2008 06:41 AM
writing binary file (ios::binary) Ron Eggler C++ 9 04-28-2008 08:20 AM
A 64-bit binary returning a value to a 32-bit binary? spammenotplui31@yahoo.ca C Programming 12 04-08-2007 07:02 AM
Re: ostreams, ios::binary, endian, mixed binary-ascii Marc Schellens C++ 8 07-15-2003 12:27 PM



Advertisments