data conversion error when assigning function to function pointer
Posted on 2007-03-21
I am trying to assign a function to a function pointer member in CFactoryTemplate, which is a class from directshow SDK
this is the class that i wrote:
class CMYFilter: public CTransInPlaceFilter
CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
What i am trying to do is assign CreateInstance to a member of type
which has its original declaration as
typedef CUnknown *(CALLBACK *LPFNNewCOMObject)(LPUNKNOWN pUnkOuter, HRESULT *phr);
the assignment is shown here:
CFactoryTemplate g_Templates =
CMYFilter::CreateInstance, // line with error
I kept receiving this error message at the line CMYFilter::CreateInstance.
error C2440: 'initializing' : cannot convert from 'CUnknown *(__cdecl
CMYFilter::* )(LPUNKNOWN,HRESULT *)' to 'LPFNNewCOMObject'
1> None of the functions with this name in scope match the target type
This is very strange since all the sample codes, including those came with
SDK, were written like this.
Is there any reason why this is happening?