[C ++] struct keyword

URL connection

https://www.cnblogs.com/zhengfa-af/p/8144786.html

 

main content:

1. C language, 3 declared and defined manner different structure;

2. struct difference in the C and C ++. C ++ function can be added in a struct, similar to class;

3. C ++, the difference between struct and class.

Member of the struct default permissions are public, members of the class of default permissions are private;

The default inheritance struct are public, default inheritance class is private;

4. The role of structure - package;

The size and structure of the memory alignment;

In order to improve the speed of memory, VC stored in the starting address of the variable structures in the body is "aligned" operation.

1) the default alignment: the start address of each member of the structure relative to the start address offset of the memory structure must be a multiple of the current size of memory occupied by members (number of bytes). Meanwhile, VC memory size in order to ensure the number of bytes structure boundaries (i.e., the maximum number of bytes of memory for a structure member type) multiples, after the final application in a memory variable, according to the number of bytes needed to fill the appropriate .

2) Providing #pragmapack (n) in the VC in the variable n is set to byte alignment.

 

 

Guess you like

Origin www.cnblogs.com/gdut-gordon/p/11516615.html