struct members memory layout

前端 未结 6 2020
既然无缘
既然无缘 2021-01-04 14:00

If I have a struct like this:

struct S {
    ANY_TYPE a;
    ANY_TYPE b;
    ANY_TYPE c;
} s;

Can I safely assume that the following assump

6条回答
  •  春和景丽
    2021-01-04 14:44

    In C++ you can be certain that these assumptions will hold. In struct like this, the compiler is not allowed to change the order of the members.

提交回复
热议问题