When overloading the comparison operators, do they return an int or a bool data type?
When overloading the comparison operators, do they return an int or a bool data type?
Operator overloading means you define what the operator functions do in relation to objects of your class. When you overload the comparison operators, you can have them return the string "Hello world" if you want. It's entirely up to you. Just like any other function, you define the operator functions to do whatever you want them to do.
Last edited by 7stud; 04-02-2003 at 12:48 AM.
true, but most of the time:
>
<
>=
<=
etc.
would return bool.
comparison operators return bool
arithmetic operators return objects
assignment and arithmetic assignment returns a reference to *this
>> and << stream operators return a reference to the stream.
Thats probably about the most general advice I can give.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi