Skip to main content
GameDev.net gamedev.net
🔒 Locked

returning polymorphic class pointers from function pointers

Started by billybob Mar 8, 2003 at 9:58 PM 0 replies 200+ views
Original Post
billybob
billybob
i'm having trouble make a function pointer return a class thats derived from that function pointer's return value. it says:
:\XGP\Engine\Actor.cpp(4) : error C2664: '__thiscall CClass::CClass(class CString,class CString,class CObject *(__cdecl *)(void),class CString (__cdecl *)(void),class CString (__cdecl *)(void))'
: cannot convert parameter 3 from 'class CActor *          (__cdecl *)(void)' to 'class CObject *          (__cdecl *)(void)'           
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
     
CActor is derived from CObject, but it still doesn't work. i was thinking about pointers to pointers, and dereferncing it in function call, but i want to know why this doesn't work also edit: the italic part is the message that matters, the bold are the two classes that should be able to be convert without a cast edit again: i also have two other function pointers set up EXACTLY the same way except for the return value, and they both work, so i'm almost positive its the function return values and not the functions themselves. [edited by - billybob on March 8, 2003 11:00:18 PM] [edited by - billybob on March 8, 2003 11:03:42 PM]
billybob
billybob
DOH, fixed it sorry. i changed the return type of my CreateInstance functions to CObject, which CAN return polymorphic types. sorry about the useless thread

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.