What's wrong with operator overloading?

This is a discussion on What's wrong with operator overloading? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Why do some languages, D, for example, seem to think operator overloading is a bad thing to have in a ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    79

    What's wrong with operator overloading?

    Why do some languages, D, for example, seem to think operator overloading is a bad thing to have in a language?
    All generalizations are false

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Because you can screw stuff up with it, and overload operatures that just don't fit. Still, I am believe that it can be helpful sometimes (especially when writing classes directly related to math).

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    no its just no body till its to late realizes their value...

    Operator overload while dangerour GIVES THE PROGRAMMER POWER TO CAUSE ERRORS THIS IS BAD ACCORDING TO THE RETARDS WHO WRITE LANGUAGES NOW DAYS...

    if you can use it and cause an error then its bad and sould be eliminated or slowed down so much during runtime by error checking you cant use it anyway...

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    79
    Operator overload while dangerour GIVES THE PROGRAMMER POWER TO CAUSE ERRORS
    Because you can screw stuff up with it,
    Could you give an example of this?

    and overload operatures that just don't fit
    That seems like a rather silly reason to abolish such a potentially powerful construct from a language.
    All generalizations are false

  5. #5
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Because it allows you to do this:

    Code:
    class a
    {
    public:
        int one;
        
    };
    
    
    int operator+ (a b,a c){return b.one-c.one;}
    
    
    int main() 
    { 
    a b;
    b.one=10;
    a c;
    c.one=8;
    cout << b+c;
    
    return 0;
    } 
    What they are saying is that programmers haven't got the common sense not to do this.

  6. #6
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    >What they are saying is that programmers haven't got the common sense not to do this.

    guess so...

    and what are their alternatives for this then? just having the programmer take the long hand?
    hasafraggin shizigishin oppashigger...

  7. #7
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    While that I agree it's non-sense to get rid of it from a langauge, it's also not all that much of a "powerful construct". All it does is change syntax. It enables nothing new, other than sometimes more readable code.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  8. #8
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459

    well said silent strike...

    it is a debate whether or not overloading operators are worth the coding time they make up for... i think that it depends on the case... if you exploit it enough, then yes... like functions for example, they are a staple of this idea... but if you don't use it to the extent that it will be efficient, then there is no reason to have it... (there are many parts of C++ which i have not used yet as they are impractical on my scale right now... take heed of this...)
    hasafraggin shizigishin oppashigger...

  9. #9
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    i disagree you'll find as you program more that operator overloading is a very powerful and neccessary resource...

    >Could you give an example of this?

    i won't right the code but i'll say it

    i could in fact make divid multiply, plus open a file, minus exit the program, and multiply display a message stating that "you suck!"...ect.ect. this leads to unreadable code...

    they seem to think we lack self control... and will make an unreadable unusable mess out of a program...

    being the great friends they are they tell us its for our own good...
    you don't need a pencil you could write words that could harm you... sounds like a comie programming language to me... hehehehehe j/k

    look at java no pointers no references no new no delete no over/under accessing arrays... hence no power

    if having pointers means i can screw something up then so be it...

  10. #10
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    The reason why java doesn't have operating overloading is

    someone could define operator++ as substracting. This

    doesn't make since someone could define add_apples which

    subtracts. There's also mild problems like you can't define

    your operators precedence etc.

  11. #11
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    >if having pointers means i can screw something up then so be it...

    i couldn't have said it better myself...
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 04:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 01:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 02:04 PM

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