, , QueryInterface B A, QueryInterface A . ,
QI(A)->B
QI(QI(A)->B)->A
, . 4.2, , , , :
void AssertSymmetric(ICar *pCar) { if (pCar) { IPlane *pPlane = 0; // request a second type of interface // HRESULT hr = pCar->QueryInterface(IID_IPlane, (void**)&pPlane); if (SUCCEEDED(hr)) { ICar *pCar2 = 0; // request original type of interface // hr = pPlane->QueryInterface(IID_ICar, (void**)&pCar2); // if the following assertion fails, pCar // did not point to a valid object // , // pCar - assert(SUCCEEDED(hr)); pCar2->Release(); } pPlane->Release(); } }
QueryInterface , , , .