overloading == with different data types

This is a discussion on overloading == with different data types within the C++ Programming forums, part of the General Programming Boards category; I can't seem to figure out how to overload the == operator. I want to add a float and a ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    2

    overloading == with different data types

    I can't seem to figure out how to overload the == operator. I want to add a float and a float* by taking the float and adding it's value to the value I get by doing temp.poi=*point. However, my compiler doesn't seem to recognize this, it says when I try to use it the use is invalid. I'm guessing that you can't add values of different types, but if anyone knows how, please, help.

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    You can by casting them. But operator-overloading is for user-defined types, and float and float* are not.

  3. #3
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    overload the == operator. I want to add a float and a float*
    Then why do you need to overload the operator== ?

    like rmullen3 said "just cast it"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework help
    By mkdl750 in forum C Programming
    Replies: 45
    Last Post: 07-17-2008, 09:44 PM
  2. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  3. Need help with my code
    By brietje698 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2007, 02:54 PM
  4. Tic Tac Toe program...
    By Kross7 in forum C++ Programming
    Replies: 12
    Last Post: 04-12-2007, 03:25 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

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