Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Need Help With Function Pointers!!!

This topic is 5814 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

Suppose I have a class CClass class CClass { private: BOOL (*fp)(BYTE n); BOOL func(BYTE n){} }; CClass::CClass { fp = func; } When I try to compile it in Visual Studio 6 i get an error: error C2440: ''='' : cannot convert from ''int (__thiscall CClass::*)(unsigned char)'' to ''int (__cdecl *)(unsigned char)'' There is no context in which this conversion is possible. Can somebody help me out. I just can''t seem to find the problem here. Thanks

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
There is a difference between a global/static function and a member function. Therefore, a member function pointer is different from a normal function pointer:

  class CClass {
BOOL (CClass::*fp)(BYTE n);
BOOL func(BYTE n)

fp = func;

// call fp on this object


Notice that you need an object to call the member function pointer on. The actual call is accomplished with the following syntax:
// or

Hope this helps.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!