The implementation of the interface and the implementation and use of QueryInterface
This article introduces the implementation of the interface and the implementation and use of QueryInterface, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
# include # include using namespace std
Interface IX: public IUnknown
{
Virtual void _ stdcall Fx () = 0
}
Interface IY: public IUnknown
{
Virtual void _ stdcall Fy () = 0
}
Interface IZ: public IUnknown
{
Virtual void _ stdcall Fz () = 0
}
Static const IID IID_IX = {0xff5ba880, 0xa371, 0x4a42, {0x87, 0x20, 0x96, 0xe0, 0x4d, 0x68, 0xd, 0x76}}; / / {FF5BA880-A371-4a42-8720-96E04D680D76}
Static const IID IID_IY = {0xde44d538, 0xe926, 0x4d5f, {0x94, 0x5d, 0x61, 0x83, 0x86, 0x7c, 0x63, 0x41}}; / / {DE44D538-E926-4d5f-945D-6183867C6341}
Static const IID IID_IZ = {0x91157d15, 0x22b1, 0x45d9, {0xb4, 0xc9, 0x81, 0x3, 0x8d, 0xec, 0xef, 0xad}}; / / {91157D15-22B1-45d9-B4C9-81038DECEFAD}
Class CA: public IX
Public IY
{
Public:
Virtual HRESULT _ stdcall QueryInterface (REFIID riid, _ _ RPC__deref_out void * * ppvObject)
Virtual ULONG _ stdcall AddRef () {return 0;}
Virtual ULONG _ stdcall Release () {return 0;}
Virtual void _ stdcall Fx () {cout