Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class IGame
- {
- public:
- virtual ~IGame(){};
- virtual void move_up(INFO &info)=0;
- }
- #define INFO std::pair<struct GetMap*, struct WhereAmI*>
- class CGame
- {
- private:
- IGame *game;
- int score;
- std::pair<struct GetMap*, struct WhereAmI*> info; // game information
- std::vector<std::function<void(std::pair<struct GetMap*, struct WhereAmI*>&)>> ptr_move_ft; //function pointer vector
- public:
- CGame();
- ~CGame();
- void return_get_map(INFO &info);
- }
- CGame::CGame()
- {
- game = new Snake();
- this->info = std::make_pair(init_map(MAP_PATH_SNAKE,0), game->init_player());
- ptr_move_ft.push_back(std::bind(&CGame::return_where_i_am, this,std::placeholders::_1)); //this work
- ptr_move_ft.push_back(std::bind(&game->move_up, game, std::placeholders::_1)); //this create a error
- }
- source/CGame.cpp: In constructor ‘arcade::CGame::CGame()’:
- source/CGame.cpp:131:44: error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say ‘&arcade::IGame::move_up’ [-fpermissive]
- ptr_move_ft.push_back(std::bind(&game->move_up, game, std::placeholders::_1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement