Thread: Quick question about operator overloading

  1. #1
    Registered User
    Join Date
    Feb 2003

    Quick question about operator overloading

    When overloading the comparison operators, do they return an int or a bool data type?

  2. #2
    Registered User
    Join Date
    Apr 2003
    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.

  3. #3
    Registered User
    Join Date
    Nov 2002
    true, but most of the time:


    would return bool.

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    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 :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM