2
03-21-2001, 07:51 AM
Hi. I'm trying to do something a little complicated. I'm trying to create a pointer to a virtual function in an instance of a class I created, which isn't of the baseclass type. Ideally, the function pointer should link to the derrived class's function.
In code...
class CBaseClass
{
public:
virtual void Function( void );
};
class CDerrivedClass : public CBaseClass
{
public:
void Function( void ) { }
};
CBaseClass *object;
//Pretend we're in a GLOBAL function, and everything has been initialized...
void (* Func)( void ) = object->Function;
/*This will generate the error (in MSVC++ 6.0)...
"Cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)"
And I don't know how to fix this. Any help would be greatly appreciated. Thanks a bunch! (Oh and typecasting doesn't work...)*/
In code...
class CBaseClass
{
public:
virtual void Function( void );
};
class CDerrivedClass : public CBaseClass
{
public:
void Function( void ) { }
};
CBaseClass *object;
//Pretend we're in a GLOBAL function, and everything has been initialized...
void (* Func)( void ) = object->Function;
/*This will generate the error (in MSVC++ 6.0)...
"Cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)"
And I don't know how to fix this. Any help would be greatly appreciated. Thanks a bunch! (Oh and typecasting doesn't work...)*/