I attempted to overload the == operator for one of my classes, I even copied a previous implementation of it, but now that I am using pointers it refuses to function properly here is the relevant code (there is a lot so I will provide more if need be)
#ifndef __MESSAGE_H
#define __MESSAGE_H
#include <iostream>
using namespace std;
class Message
{
public:
Message(int idnum, char* inmsg);
~Message();
Message(const Message* &m);
Message & operator= ( const Message & assignFrom );
bool operator== ( const Message* & m ) const;
bool operator!= ( const Message* & m ) const;
friend istream & operator>> ( istream is, Message* &m);
friend ostream & operator<< ( ostream os, const Message* &m );
private:
int id; // Message Identifier
int size; // Current number of chars allocated for Message
int count; // Current number of chars stored in Message
char * msg; // Stores the message data
static const int GROW_BY = 10;
void Grow();
};
and then the implementation in the .cpp file...
bool Message::operator== ( const Message* & m ) const
{
return id == m->id;
}
and where the problem is...
InfoType * LList::Find ( const InfoType & x ) const
{
Node* p = list;
if(p != NULL)
while(p != NULL)
{
if(p->infoPtr != NULL && *p->infoPtr == x)
return p->infoPtr;
p = p->next;
}
return NULL;
}
Note: I used typedef Message* InfoType and infoPtr is an InfoType* pointer; the issue being where it says *p->infoPtr == x reading: Error 3 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Message' (or there is no acceptable conversion) j:\2630\prog21\llist.cpp 54 1
Thanks for your help!