Binary operator

Discussion in 'C++' started by Binary, Oct 24, 2006.

  1. Binary

    Binary Guest

    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
     
    Binary, Oct 24, 2006
    #1
    1. Advertising

  2. Binary

    dasjotre Guest

    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?
     
    dasjotre, Oct 24, 2006
    #2
    1. Advertising

  3. Binary

    Ron Natalie Guest

    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.
     
    Ron Natalie, Oct 24, 2006
    #3
  4. 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
     
    =?ISO-8859-15?Q?Juli=E1n?= Albo, Oct 24, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fangs
    Replies:
    3
    Views:
    9,801
    darshana
    Oct 26, 2008
  2. Marc Schellens
    Replies:
    8
    Views:
    3,023
    John Harrison
    Jul 15, 2003
  3. Replies:
    12
    Views:
    582
    Richard Heathfield
    Apr 8, 2007
  4. Ron Eggler

    writing binary file (ios::binary)

    Ron Eggler, Apr 25, 2008, in forum: C++
    Replies:
    9
    Views:
    936
    James Kanze
    Apr 28, 2008
  5. Don
    Replies:
    60
    Views:
    1,364
    Phred Phungus
    Mar 19, 2010
Loading...

Share This Page