Like Tree10Likes
  • 8 Post By brewbuck
  • 1 Post By Elysia
  • 1 Post By Alexandre

Overloading + operator

This is a discussion on Overloading + operator within the C++ Programming forums, part of the General Programming Boards category; Can '+' operator be overloaded to multiply two integers?? and... Is it possible to overload '=' operator??...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    385

    Overloading + operator

    Can '+' operator be overloaded to multiply two integers??
    and...
    Is it possible to overload '=' operator??

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,762
    [13] Operator overloading ..Updated!.., C++ FAQ

    > Can '+' operator be overloaded to multiply two integers??
    [13] Operator overloading ..Updated!.., C++ FAQ
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    385
    Thank you!!

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Not built-in integers. User-defined integer types, sure.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,263
    Quote Originally Posted by juice View Post
    Can '+' operator be overloaded to multiply [...]
    Sir, drop the compiler and STEP AWAY from the computer. Slowly. With your hands on your head.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    Quote Originally Posted by juice View Post
    Can '+' operator be overloaded to multiply two integers??
    and...
    Is it possible to overload '=' operator??
    Just because you can do this doesn't mean you should. Because it doesn't make sense.
    Use it for experimentation purposes only!!
    Salem likes this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Aug 2011
    Location
    Montreal, Quebec, Canada
    Posts
    73
    Quote Originally Posted by brewbuck View Post
    Sir, drop the compiler and STEP AWAY from the computer. Slowly. With your hands on your head.
    It should look something like this:

    ……………………………………..________
    ………………………………,.-€˜€……………….“~.,
    ………………………..,.-€……………………………..€œ-.,
    …………………….,/………………………………………..€:,
    …………………,?………………………………………………\,
    ………………./…………………………………………………..,}
    ……………../………………………………………………,:`^`..}
    ……………/……………………………………………,:€………/
    …………..?…..__…………………………………..:`………../
    …………./__.(…..€œ~-,_…………………………,:`………./
    ………../(_….€~,_……..€œ~,_………………..,:`…….._/
    ……….{.._$;_……€=,_…….€œ-,_…….,.-~-,},.~€;/….}
    ………..((…..*~_…….€=-._……€œ;,,./`…./€…………../
    …,,,___.\`~,……€œ~.,………………..`…..}…………../
    …………(….`=-,,…….`……………………(……;_,,-€
    …………/.`~,……`-………………………….\……/\
    ………….\`~.*-,……………………………….|,./…..\,__
    ,,_……….}.>-._\……………………………..|…………..`=~-,
    …..`=~-,_\_……`\,……………………………\
    ……………….`=~-,,.\,………………………….\
    …………………………..`:,,………………………`\…………..__
    ……………………………….`=-,……………….,%`>–==“
    …………………………………._\……….._,-%…….`\
    ……………………………..,< `.._|_,-&``................`\
    Salem likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. overloading >> operator
    By Diamonds in forum C++ Programming
    Replies: 1
    Last Post: 03-21-2003, 02:01 AM
  2. Operator overloading
    By Trauts in forum C++ Programming
    Replies: 7
    Last Post: 12-10-2002, 10:03 AM
  3. Operator Overloading (=)
    By mikeadi in forum C++ Programming
    Replies: 4
    Last Post: 12-01-2002, 08:22 PM
  4. operator overloading
    By tsut in forum C++ Programming
    Replies: 1
    Last Post: 03-29-2002, 09:26 AM
  5. operator overloading
    By Kohatian 3279 in forum C++ Programming
    Replies: 1
    Last Post: 03-28-2002, 09:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21