shlagish
11-03-2009, 12:21 AM
This is part of a code I'm writing as a school assignment. The problem has nothing to do with the homework topic (semaphores).
Here is what I have:
void Jeu::lancer()
{
vector<Joueur*>::iterator joueur = joueurs_.begin();
while(joueur != joueurs_.end())
{
*joueur->jouer(); // This is the tricky bit
++joueur;
}
}
Jeu is a class which has a private member joueurs_ which is a vector of pointers to objects of class Joueur. It is declared like this:
vector<Joueur*> joueurs_;
The public method lancer() is supposed to call, for every Joueur in vector joueurs_, it's own public method jouer().
This is the compilation error I get, which I don't quite understand..
jeu.cpp:20: error: request for member ‘jouer’ in ‘* joueur.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = Joueur**, _Container = std::vector<Joueur*, std::allocator<Joueur*> >]()’, which is of type ‘Joueur*’ which is not a class
This is translated from spanish so the words might not be exact.,,
I think I might not be fetching the object correctly, but I tried many different ways, and none of the following work:
*joueur->jouer();
**joueur->jouer();
***joueur.jouer();
Does anybody understand what I'm doing wrong here?
Thanks a bunch in advance
Here is what I have:
void Jeu::lancer()
{
vector<Joueur*>::iterator joueur = joueurs_.begin();
while(joueur != joueurs_.end())
{
*joueur->jouer(); // This is the tricky bit
++joueur;
}
}
Jeu is a class which has a private member joueurs_ which is a vector of pointers to objects of class Joueur. It is declared like this:
vector<Joueur*> joueurs_;
The public method lancer() is supposed to call, for every Joueur in vector joueurs_, it's own public method jouer().
This is the compilation error I get, which I don't quite understand..
jeu.cpp:20: error: request for member ‘jouer’ in ‘* joueur.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = Joueur**, _Container = std::vector<Joueur*, std::allocator<Joueur*> >]()’, which is of type ‘Joueur*’ which is not a class
This is translated from spanish so the words might not be exact.,,
I think I might not be fetching the object correctly, but I tried many different ways, and none of the following work:
*joueur->jouer();
**joueur->jouer();
***joueur.jouer();
Does anybody understand what I'm doing wrong here?
Thanks a bunch in advance