Hi I am not one for using virtual inheritance or pointers to functions if I can help it, but I am trying to start to learn the basics of direct x and it was recommended i knew a bit about COM first. I was very happy with it until I got to this function which confused me.
Code:
HRESULT __stdcall CCOM_OBJECT::QueryInterface(const IID &iid, void **iface)
{
// this function basically casts the this pointer or the iunknown
// pointer to the interface requested, notice the comparison with
// the GUIDs generated and defined in the beginning of the progra,
// requestiong the IUNKNOWN base interface
if (iid == IID_IUnknown)
{
cout << "Requesting IUnknown interface" << endl;
*iface = (IX*)this;
}
if (iid == IID_IX)
{
cout << "Requestiong IX interface" << endl;
*iface = (IX*)this;
}
else
{
if (iid == IID_IY)
{
cout << "Requestion IY interface" << endl;
*iface = (IY*)this;
}
else
{
cout << "Requesting Unknown interface!" << endl;
*iface = NULL;
return(E_NOINTERFACE);
} // end else
}
// if everthing went well cast pointer to IUNKNOWN and call addref()
((IUnknown *)(*iface))->AddRef();
return (S_OK);
}
Now my problem is I have no idea what parameter this is
void **iface
at first i thought it was a pointer to a function but that cant be because it gets set to *iface = (IY*)this; which by its nature isn't a function so im completely confused. Even by the line that calls the function which is
punknown->QueryInterface(IID_IY, (void**)&piy);
Somebody please help