大家看看这个函数到底调用的是那个??(答完立即结帖)
class IUnknown
{
virtual HRESULT __stdcall QueryInterface(const IID & , void **) = 0 ;
};
class INondelegatingUnknown
{
virtual HRESULT __stdcall
NodelegatingQueryInterface(const IID & , void **) = 0 ;
};
class CB : public IUnknown , INondelegatingUnknown
{
virtual HRESULT __stdcall QueryInterface(const IID & , void **)
{
.........
}
virtual HRESULT __stdcall
NodelegatingQueryInterface(const IID & , void **)
{
.........
}
};
class CA : public IUnknown
{
virtual HRESULT __stdcall QueryInterface(const IID & , void **)
{
.........
}
void Init()
{
IUnknow *ppv = NULL ;
//然后ppv通过某种途径获得ppv = static_cast<INondelegatingUnknown *>(this) 而this指向一个CB类
ppv->QueryInterface(iid , p) ;
//问此时ppv调用的是CB中的那个函数(QueryInterface()还是NodelegatingQueryInterface())
}
};