C ++ byte alignment (target size)

Internal data alignment reference this member

https://www.cnblogs.com/area-h-p/p/10316128.html

Here only emphasize C ++ byte alignment features

① static data members belong to the class domain, not the size of the object

② If the class has virtual functions virtual table is generated, the size of the object +4

Size class object class, member function, or only the data members ③ no 1

Example 1

 

 Internal data after alignment members 12, 16 is the virtual table plus

Example 2

 

 Only member function, the object size is 1.

Guess you like

Origin www.cnblogs.com/area-h-p/p/12190759.html