Thread: Operator Overload

  1. #1
    Village id10t
    Join Date
    May 2008

    Operator Overload

    Can someone please direct me to a nice, easy tutorial regarding the overloading of operators. My textbook isnt very clear and the sites i looked at seemed a bit too complex.


  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Have you tried googling?

    Here's a selection that looks good from the first page of

    I didn't spend many seconds on each of those pages, so I can't say I "recommend" any of them

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Hampton, VA
    Or even better, if you have a specific example you need some help with, there are many individuals here who can help you...

    But basically, the way to overload an operator follows ( loosely ) this general format:

    return_type operatorXX( arguments ){ return statements }
    /*  Where XX is the operator in question */
    You have some flexibility in writing your oerators, just be careful to only write operators that make sense and that their return-type and use are intuitive to the end user. In other words overloaded operators shouldn't "confuse" a user.
    Ubuntu Desktop
    Geany (for quick projects)
    Anjuta (for larger things)

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    Or in other words, don't overload a + operator that does subtraction (or the like)
    The overloaded operators should make sense!
    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.

Popular pages Recent additions subscribe to a feed