I am trying to use an iterator over listpointers:
int main () {
list<Game*> Games;
Games = build_list_from_file();
list<Game*>::iterator it = Games.begin();
it++;
cout << *it->get_name() << endl ;
}
When I compile it, I have this error:
error: request for member ‘get_name’ in ‘* it.std::_List_iterator<_Tp>::operator-><Game*>()’, which is of pointer type ‘Game*’ (maybe you meant to use ‘->’ ?)
cout << *it->get_name() << endl ;
^
Gameis a class that has a member function get_namethat returns the name of the game. What to do to make this compilation?
source
share