转载:
http://www.artima.com/cppsource/pure_virtual.htmlWhen 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:.
- Make the instance point to the base class's vtbl.
- Construct the base class instance member variables.
- Execute the body of the base class constructor.
Step 2: Construct the derived part(s) (recursively):
- Make the instance point to the derived class's vtbl.
- Construct the derived class instance member variables.
- Execute the body of the derived class constructor.
Destruction happens in reverse order, something like this:
Step 1: Destruct the derived part:
- (The instance already points to the derived class's vtbl.)
- Execute the body of the derived class destructor.
- Destruct the derived class instance member variables.
Step 2: Destruct the base part(s) (recursively):
- Make the instance point to the base class's vtbl.
- Execute the body of the base class destructor.
- Destruct the base class instance member variables.
posted on 2010-08-16 18:57
Uniker 阅读(1408)
评论(0) 编辑 收藏 引用