To pass a pointer to a member function

后端 未结 4 781
闹比i
闹比i 2021-01-13 03:51

I have an class with instance functions (or methods?). From within an instance, I try to pass pointers to those functions to a library. The library expects static functions

4条回答
  •  别那么骄傲
    2021-01-13 04:33

    What you are trying to do is not possible. This is glut's fault actually.

    The thing is this:

    • glut wants to call a function, without giving it data,
    • You want your function to use some data,

    which are conflicting needs. I believe glut decided you can safely use global variables.

    So, one solution is to use static functions, with static data. Or a better solution would be to switch to SDL.

提交回复
热议问题