COM foundation (continued)

xiaoxiao2021-03-06  63

There is no picture in the previous section:

Class cfoo: public ifoo {

Void func1 () {/ * ... * /}

Void func2 (int ncount) {/ * ... * /}

}

The client may be:

#include

Void Dofoo () {

Ifoo * pfoo = fn_that_gets_an_ifoo_pointer_to_a_cfoo_Object ();

// Call The Methods.

Pfoo -> func1 ();

Pfoo -> Func2 (5);

}; The steps call in the figure are:

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

The vTable Pointer is dereferenced and indexed to find the address of the function to be called.3, the function is called.

转载请注明原文地址:https://www.9cbs.com/read-113115.html

New Post(0)