随笔 - 3  文章 - 0  trackbacks - 0

留言簿

随笔分类

随笔档案

要记得经常点击我哦

搜索

  •  

最新评论

阅读排行榜

评论排行榜

转载:http://www.artima.com/cppsource/pure_virtual.html
When you construct an instance of a derived class, what happens, exactly? If the class has a vtbl, the process goes something like the following:

Step 1: Construct the top-level base part:.

  1. Make the instance point to the base class's vtbl.
  2. Construct the base class instance member variables.
  3. Execute the body of the base class constructor.

 

Step 2: Construct the derived part(s) (recursively):

  1. Make the instance point to the derived class's vtbl.
  2. Construct the derived class instance member variables.
  3. Execute the body of the derived class constructor.

 

Destruction happens in reverse order, something like this:

Step 1: Destruct the derived part:

  1. (The instance already points to the derived class's vtbl.)
  2. Execute the body of the derived class destructor.
  3. Destruct the derived class instance member variables.

 

Step 2: Destruct the base part(s) (recursively):

  1. Make the instance point to the base class's vtbl.
  2. Execute the body of the base class destructor.
  3. Destruct the base class instance member variables.
posted on 2010-08-16 18:57 Uniker 阅读(1385) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理