When C ++ was developed, the developers found out that C programmers rely on some things that C ++ developers did not want to guarantee, but without guaranteeing them, would mean that a lot of C code, which was also valid, C ++ code would break when used as C ++ code. Undesirable.
That's why they invented the "POD" structure: a structure that didn't use any C ++ functions could behave in a C ++ program exactly the same as in a C program (except that the behavior defined by the implementation can change , since the C compiler and the C ++ compiler are clearly not the same implementation. On the other hand, the C ++ compiler will probably just copy the implementation definition from the C compiler).
If you take some simple C-structure, which is also a valid C ++ structure (for example, not members with the name "class"), and then you just add "public:" right after opening the bracket, then its layout, order members, alignment, etc. everything can change. Although all members of the structure are public by default, nothing has changed. Except that due to the "public" it is no longer a POD.
gnasher729 Nov 21 '15 at 19:38 2015-11-21 19:38
source share