compare.cpp

来自「VC++串口通信设。本书详细说明讲解了在VC++环境下编写串口通信得过程。值得一」· C++ 代码 · 共 35 行

CPP
35
字号
//... IDog interface pointer is in variable pIDog ...
//... IChihuahua interface pointer is in variable pIChihuahua ...

HRESULT result              = E_FAIL;
IUnknown* pDogIUnknown      = NULL;
IUnknown* pChihuhuaIUnknown = NULL;

// Get the IUnknown interface pointer for the IDog
result = pIDog->QueryInterface(IID_IUnknown, (void**) &pDogIUnknown);

if (FAILED(result)) 
{
   // ... Error processing ...
}

// Get the IUnknown interface pointer for the IChihuahua
result = pIChihuahua->QueryInterface(IID_IUnknown, (void**) &pChihuahuaIUnknown);

if (FAILED(result)) 
{
   // ... Error processing ...
}

// Do both of these interface pointers belong to the same object?
if (pDogIUnknown == pChihuahuaIUnknown) 
{
   cout << "The IDog and IChihuahua interfaces belong to "
           "the same component.\n";
{
else
{
   cout << "The IDog and IChihuahua interfaces DO NOT belong to "
           "the same component.\n";
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?