Jump to content
  • Advertisement


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


Functon pointers

This topic is 5781 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 use function pointers in my CScript class, however they seem to not be working. I belive the problem lies in my typedef:
typedef int (*pFunc)(CGame*);
This is supposed to be a typedef for a func-pointer take a CGame pointer as an argument and returning an integer. Later on in my code I call it like this:
void CCommand::Execute(CGame *pGame)
	int Result;
	Result = pFunc(pGame);
pFunc is a private member of CCommand. But I get an error message telling me that
C:\...\CCommand.cpp(46) : error C2440: ''='' : cannot convert from ''int (__cdecl *)(class CGame *)'' to ''int'' 
Why wouldnt this work? is it my typedef, or could it be something else?

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!