1
I started studying object orientation and I’m trying to call pointer to method, but I’m having difficulties.
The implementation of the method startAllegro class Application 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 pointer is the quitSwap, in routine set_close_button_callback.
set_close_button_callback is a routine of Allegro 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 the method startAllegro:
application.cpp:20: error: argument of type 'void (Application::)()' does not match 'void (*)()'
I’ve tried everything to solve but could not. Could someone more experienced in POO help me? Thanks
Um... maybe a casting of the solve function. Try to make the call like this:
set_close_button_callback((void (*)(void)) quitSwap);– Luiz Vieira