Thread: Please explain overloading arithmetic and relational operators

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    10

    Question Please explain overloading arithmetic and relational operators

    I vaguely understand the concept of overloading, but I do not understand how this applies to relational operators like <, <= and ==. I also do not understand how to overload addition, subtraction, multiplication and division, and I do not understand the logical reasoning behind overloading them.

    Could you please explain this to me? Thank you very much!

    ex: ( a*b + b*c ) / ( b*c ) Why is overloading better?*

    *This is not an assignment question, but a question relating to an assignment. The assignment assumes we already understand overloading, and as this is my only independent study class, well... if I'm my own teacher and I don't understand it, how am I supposed to do the homework?

    Can someone actually just write out how to overload the addition function? Just the simple stuff that I can't seem to grasp no matter how many websites I cruise. what comes in the .cpp file??

    I think it starts out as const operator+ ...
    but then I have no idea where it does from there in the header file, and the .cpp file is completely beyond me.

    Thanks.
    Last edited by aperson; 11-30-2008 at 04:54 PM. Reason: Narrowing question

Popular pages Recent additions subscribe to a feed

Tags for this Thread