CSDN博客

img pengdekui

COM基础(续)

发表于2004/9/25 16:47:00  1111人阅读


上一节没有谈到的一幅图:
class CFoo : public IFoo {
   void Func1() { /* ... */ }
   void Func2(int nCount) { /* ... */ }
};

客户端可能是:

#include <IFOO.H // Don't need CFoo, just the interface
void DoFoo() {
  IFoo *pFoo = Fn_That_Gets_An_IFoo_Pointer_To_A_CFoo_Object();

  // Call the methods.
  pFoo -> Func1();
  pFoo -> Func2(5);
};

图中调用的步骤是:

1,
pFoo is dereferenced to find the vtable pointer in the object.
2,


  1. The vtable pointer is dereferenced and indexed to find the address of the function to be called.

3,
The function is called.





阅读全文
0 0

相关文章推荐

img
取 消
img