所以我有一个这样声明的向量:
vector <Game *> games;
Game
我在类中有一个函数,如下所示:
public:
// Rest of .h
void hello(){
cout << "hello" << endl;
}
我正在尝试games
使用迭代器迭代我的向量,并hello()
每次调用该函数:
vector <Game *>::const_iterator it_games = games.begin();
for (it_games = games.begin(); it_games != games.end(); it_games++) {
*it_games->hello();
}
但是当我尝试编译时,我不断收到此错误:
main.cpp: In function ‘void summary(std::vector<Game*, std::allocator<Game*> >, std::string, std::string, std::string, std::string)’:
main.cpp:56: error: request for member ‘hello’ in ‘* it_games. __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = Game* const*, _Container = std::vector<Game*, std::allocator<Game*> >]()’, which is of non-class type ‘Game* const’
知道发生了什么/如何获得所需的功能吗?