C + + object Model-Object model

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.