Original Post
Hi!
I''m trying to program a registering process in which any class instance can send one of it''s method to a "call manager". So, I need to point to a method of an object. I know how I can do this for a known object type, by receiving (TMyClass::*fpFunc)... but I don''t know how to do this if I don''t know this type. I''ve read I could receive the object AND the function pointer (the adress and the offset), but I can''t make this work. Below is a code that is working for global or static __cdecl functions.
//**********************************************
class A;
class B;
class C;
class A
{
public:
A() {}
~A() {}
void SomeFunction( char* SomeParam );
};
class B
{
public:
B() {}
~B() {}
void SomeOtherFunction( char* SomeParam );
};
class C
{
public:
C() {}
~C() {}
void SetFunctionPointer( void (*_fpFunc) ( char* SomeParam ) )
{
fpFunc = _fpFunc;
}
private:
void (*fpFunc) ( char* SomeParam );
};
C oC;
void main( void )
{
A oA;
B oB;
//oC.SetFunctionPointer( oA.SomeFunction );
//oC.SetFunctionPointer( oB.SomeOtherFunction );
}
//**********************************************
So, briefly, I want to store an unknown object adress and one of it''s method in another object, so I can call it later.
Thanks for any help or hints.
Let''s program!
Sherlock