Class Storage Structure

Source: Internet
Author: User

. Where there are virtual functions and real inheritance: location distribution in the storage area: pointing to the virtual function table (both the parent class and its own virtual functions are in place, and the parent class is in front) pointer + parent class variable + Child class variable behind

 

 

In the case of virtual functions and real inheritance (in the case of heavy loads): The storage location distribution is similar to the above: pointing to the virtual function table (both the parent class and its own virtual functions are in it, in addition, the parent class is in the front, and the Function Location of the overloaded parent class is replaced by the quilt function name. See the picture on the right.) the pointer + parent class variable is in the front + subclass variable is in the back

With virtual functions + real inheritance (ONE): The location distribution of the storage area is similar to the above: pointer to the virtual function table itself + 0 Separator of one byte + sub-class member variable in front ++The parent class member variable is behind

 

 

 

 

 

 

 

 

 

 

 

 

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.