OOPortal OOPortal


Basic COM   «Prev  Next»

COM Interface Pointer - Exercise

Objective: Write code to use a COM interface pointer.

Instructions

  1. Assume we have a pointer to interface IF1 in variable pIF1.
  2. Interface IF1 has the following IDL definition:

interface IF1 : IUnknown 
{
   HRESULT X1(INT ix);
   HRESULT X2();
}
  1. Using interface pointer pIF1, write code to call IF1::X2.
  2. Write code to call IF1::QueryInterface to query for interface IF2 using IID_IF2.

Exercise scoring

This exercise is worth 20 points; up to 10 points for each code fragment.

Exercise submission


Click Submit to submit this exercise.