Reputation: 31
What i want to do is
for (list<cPacket *>::iterator i = cache.begin(); i != cache.end(); i++){
if( strcmp(i->getName(),id) == 0 ){
return true;
}
}
where getName
is function of the class cPacket, But it does not work, i tries also
i.operator->()->getName()
, and again nothing.
Can anybody help me?
Upvotes: 2
Views: 7471
Reputation: 506
replace
list<cPacket *>::iterator i
with
list<cPacket>*::iterator i
Upvotes: -3
Reputation: 46607
*i
dereferences the iterator. As the data type of the list is pointer to cPacket
, you need to apply the ->
operator to access its members. Parentheses are needed for proper precendence:
(*i)->whatever()
Upvotes: 6