Michello
May 31st, 2002, 01:21 PM
Hello there!
Are there any opportunities of generic programming in C++ without using templates?
My problem is, that I have to call a member function defined in a derived class from its base class with a function pointer like
(pDerivedClass->*pMsgFxn)();
Therefore I register the member function with a protected template member of the base class:
template <class T> bool RegisterFxn( T* pDerivedClass, void( T::* pMsgFxn )() );
Unfortunately I'm using DLLs and in this context templates are only generated when they're used and compiled in the type they're called. So any dummy calls of this template in the DLL, in order to generate code, won't work, because I don't know the type - the name - of possible derived classes.
So how can I solve the problem without using templates? How can I call a function without knowing its type?
Thanks in advance.
Michello
Are there any opportunities of generic programming in C++ without using templates?
My problem is, that I have to call a member function defined in a derived class from its base class with a function pointer like
(pDerivedClass->*pMsgFxn)();
Therefore I register the member function with a protected template member of the base class:
template <class T> bool RegisterFxn( T* pDerivedClass, void( T::* pMsgFxn )() );
Unfortunately I'm using DLLs and in this context templates are only generated when they're used and compiled in the type they're called. So any dummy calls of this template in the DLL, in order to generate code, won't work, because I don't know the type - the name - of possible derived classes.
So how can I solve the problem without using templates? How can I call a function without knowing its type?
Thanks in advance.
Michello