• Advertisement
Sign in to follow this  

C++ Function Pointers

This topic is 3839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a huge problem trying to create a GLUT class. The problem is when it comes to setting up the callback funtions in glut. Below is a demo class that illustrates the problem: class glutTest { public: glutTest(int argc, char** argv) { // CALLBACK glutDisplayFunc(&glutTest::drawGLScene); } private: void drawGLScene(void){} }; This will not compile but dies with the following error: 'glutDisplayFunc' : cannot convert parameter 1 from 'void (__thiscall glutTest::* )(void)' to 'void (__cdecl *)(void)' If i remove the class operator and have it as follows : glutDisplayFunc(drawGLScene); i get this error: 'glutTest::drawGLScene': function call missing argument list; use '&glutTest::drawGLScene' to create a pointer to member So i've checked almost all my C++ reference books, none of them had any kind of comprehensive section on function pointers or about converting/casting them. Even googling didnt help. I'm guessing i somehow have to cast a function pointer to the right type? Can anyone help?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement