J
Jonathan
Hi. I'm having trouble figuring out what I should be doing here.
I'm trying to remove an object from a list.
The function is:
void Alive::FromRoom ()
{
list<Alive>::iterator iter = room->living.begin();
while (iter != room->living.end())
{
if (*iter == *this)
{
room->living.erase(iter);
break;
else ++iter;
}
}
The error message is:
alive.cpp:29: no match for `Alive& == Alive&' operator
which is this line:
if (*iter == *this)
I've declared 'living' here:
class Room : public Baseobj
{
list<Alive> living;
};
So, I'm not sure how I should be doing this. If the error message can
be trusted, I need to define '==' as it applies to the 'Alive' class?
But, I don't understand what that would mean. I mean, I have the object
I want to remove from the list. It's 'this'. So, I don't understand
what more would be needed. The 'this' pointer points to an instance of
an object, doesn' it?
I'm trying to remove an object from a list.
The function is:
void Alive::FromRoom ()
{
list<Alive>::iterator iter = room->living.begin();
while (iter != room->living.end())
{
if (*iter == *this)
{
room->living.erase(iter);
break;
else ++iter;
}
}
The error message is:
alive.cpp:29: no match for `Alive& == Alive&' operator
which is this line:
if (*iter == *this)
I've declared 'living' here:
class Room : public Baseobj
{
list<Alive> living;
};
So, I'm not sure how I should be doing this. If the error message can
be trusted, I need to define '==' as it applies to the 'Alive' class?
But, I don't understand what that would mean. I mean, I have the object
I want to remove from the list. It's 'this'. So, I don't understand
what more would be needed. The 'this' pointer points to an instance of
an object, doesn' it?