Hello!
Right now I'm learning FLTK, and using OOP in it.
I have a class that contains everything, and I want to have a non-static callback (as this lets me use everything in the class). Callbacks have to be static, but it is possible, according to the documentation, to call, from the callback, a non-static method.
I get the error that it cannot call the non-static method without object.
So I have tried passing a custom *this using the following method:
Code:
application::application()
{
//.....
void* ptt = &*this;
in->callback(s_enter, ptt);
//.....
}//application()
in here, we are located in the constructor, that can use *this by default.
So I pass *this as a void pointer. Then...
Code:
void application::s_enter(Fl_Widget* o, void* p)
{
application* me;
me = (application*)&p;
enter(me);
return;
}//s_enter()
I make a pointer to this class object, get *this from the void pointer, essentially getting *this in a static method.
Then I call the non-static method with the newly hand-made *this.
I still get the error!:
Code:
error: cannot call member function 'void application::enter(application*)' without object
Please point me to my mistake, because I do not see it, not now at least.
In case it helps, this is the function prototype for enter:
Code:
void enter(application*);
It never actually uses the pointer though, as I do not needed considering I have access to all of the class' attributes.