雁南飞

碧云天,黄花地,西风紧,北雁南飞。晓来谁染霜林醉?

原创  [原]C语言的面向对象 收藏

看了qualcomm的 interface, 决定把它抄下来。 主要还是方便日后查找。

1.  define the structure of virtual function table

2. define the structure of "class"

3. about the size of structure

1)  size of virtual function table

    4 bytes

2)  size of  member variable

     0xxxxx  --> original address 

     0xxxxx  --> virtual table          4B

     0xxxxx  --> member 1

     0xxxxx  --> member 2

     0xxxxx  --> member 3

   

4. initialization of stucture.

    

 1)  use static global virtual table.

 

 2)  use dynamic virtual table

 CMyFunc *pMe = (CMyFunc *) MALLOC(sizeof(CMyFunc)+sizeof(AEEVTBL(IMyFunc)));

     0xxxxx  --> original address 

     0xxxxx  --> virtual table          4B

     0xxxxx  --> member 1

     0xxxxx  --> member 2

     0xxxxx  --> member 3

     0xxxxx  --> original address of virtual table

   

将虚函数表存储在结构后面,避免使用全局,静态的存储区
 

发表于 @ 2009年03月15日 15:21:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:临时对象

  • 发表评论
  • 评论内容:
  •  
Copyright © wanfustudio
Powered by CSDN Blog