1: Simple Object model
1> Introduction: Each member uses a pointer to a real member. So the object
The size is very good OK, that is, the number of members * pointer size.
2> use: The member function is the use of this model
3> Chart:
4> Plus Inheritance: Each additional base class has one more pointer.
2: Table-driven object model
1>: Take all the information related to the members and put it in the data
Member table and member function table
2> Use: virtual function
3> Chart:
4> Plus Inheritance: Add a base table, a base PTR
Hold a PTR in the class object pointing to base table, in base
All base pointers are stored in the table. But compared to simple objects
Model, this approach will have two layers of indirect direction, so it will be more time-consuming
Room
5> Chart:
3:c++ Object Model
1> Introduction: nonstatic data members are placed within class object
Static data members are placed outside class object. Static and
nonstatic function members are placed outside class object. For
Virtual functions uses vptr to point to the VTBL. The first bit of each VTBL
The information for the placement class.
2> use: C + + objects
3> Chart:
4> Plus inheritance: instead of storing pointers, all base class
The data members are placed directly in the derived class object.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C + + object Model-Object model