In one of my methods, a function with two parameters is passed, and saved as rightClick. However, because its in a static function, the compiler wants the function to be initialised before. How can i go about this?
Mouse.cpp
void Mouse::clicked(int button, int state, int x, int y)
{
if(button == GLUT_LEFT_BUTTON) {
if(state == GLUT_DOWN) {
isDragging = true;
CurrentX = x;
CurrentY = y;
}
else
{
isDragging = false;
}
}
else if (button == GLUT_RIGHT_BUTTON)
{
if (state == GLUT_DOWN)
{
isDragging = true;
rightClick(x,y);
}
}
}
void Mouse::setRightClickFunction(void (*func)(int, int))
{
rightClick = func;
}
The setRightClickFunction is called before click ever is. Except now i'm getting a different problem : "Mouse::rightClick", referenced from: Mouse::clicked(int, int, int, int) in Mouse.o
setRightClickFunctionis static and if so, why? If not, what function does the compiler wants initialized, exactly?setRightClickFunctionfunction, before theclickedhandler is called.std::functionandstd::bind.