I started studying object orientation and I'm trying to call pointer to method, but I'm having trouble.
The implementation of the startAllegro
method of the Application
class is as follows:
void Application::startAllegro(){
allegro_init();
install_timer();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, width, heigth, 0, 0);
set_window_title(&name[0]);
set_close_button_callback(quitSwap);
}
The other method I'm trying to pass as a pointer is quitSwap
, in the set_close_button_callback
routine.
set_close_button_callback
is an allegro routine and has the following prototype: set_close_button_callback(void (*proc)(void));
The implementation I made of the quitSwap method is:
void Application::quitSwap(){
quit = true;
}
I'm getting the following error in method startAllegro
:
application.cpp:20: error: argument of type 'void (Application::)()' does not match 'void (*)()'
I have tried everything to solve, but I could not. Anyone more experienced in OOP could help me? Thanks