Является ли этот тип классом стандартной компоновки? ⇐ C++
-
Anonymous
Является ли этот тип классом стандартной компоновки?
As far as I know, a property of the standard-layout class is that the address of a standard-layout object is equal to its initial member's. I tested the following code with g++ and clang++, but found that Derived3 is a standard-layout class and &d is not equal to &d.c.
#include using namespace std; struct Base {}; struct Derived1 : Base { int i; }; struct Derived3 : Base { Derived1 c; int i; }; int main() { cout
Источник: https://stackoverflow.com/questions/780 ... yout-class
As far as I know, a property of the standard-layout class is that the address of a standard-layout object is equal to its initial member's. I tested the following code with g++ and clang++, but found that Derived3 is a standard-layout class and &d is not equal to &d.c.
#include using namespace std; struct Base {}; struct Derived1 : Base { int i; }; struct Derived3 : Base { Derived1 c; int i; }; int main() { cout
Источник: https://stackoverflow.com/questions/780 ... yout-class
Мобильная версия