Overloaded statement not detected

First a little back, I created a double list using templates. I have a class "account" in which I overloaded the operator "==" to compare account identifiers. I created a linked list for storing accounts.

When I add a new account to the list, it calls "contains?". method that calls the == operator. An error is thrown here, and g ++ tells me

sll.h: In the member function 'bool list :: contains (T) [with T = account]:

customer.h: 25: 35: instance here

sll.h: 261: 3: error: no match for 'operator == in' temp → node :: data == item

account.h: 36: 6: note: candidate: bool account :: operator == (account &)

I have been investigating for hours, and I can't figure it out. I suspect this may have something to do with the fact that I am using templates. I created a test program to check if I overload the statement correctly and it works as expected.

Also note: there is a client class, which is the list of accounts contained in it, and this is what is called the add method. Unfortunately, I cannot post more than two hyperlinks, so just take my word that this class is correctly created. = P

Since the code is somewhat long, I used pastie:

Associated List Class

Account class

+5
source share
1 answer

== const-, . BTW, == .

  • == const

  • == , .

  • ?

  • - . ?

+6

All Articles