gpt4 book ai didi

c++ - 下面[class.derived]/7中突出显示的 “of the same type”表达式是什么意思?

转载 作者:行者123 更新时间:2023-12-02 10:10:26 25 4
gpt4 key购买 nike

[class.derived]/7:

[Note: A base class subobject might have a layout ([basic.stc])different from the layout of a most derived object of the sametype. A base class subobject might have a polymorphic behavior([class.cdtor]) different from the polymorphic behavior of a mostderived object of the same type. A base class subobject may be ofzero size ([class]); however, two subobjects that have the same classtype and that belong to the same most derived object must not beallocated at the same address ([expr.eq]). — end note]

最佳答案

struct B { /* ... */ };
struct D : B { /* ... */ };

B b;
D d;
B的基类子对象 d的布局可能与相同类型( b)的最派生对象(此处为 B)不同。例如,一个实现可以为 B的成员重用 D的尾部填充。

关于c++ - 下面[class.derived]/7中突出显示的 “of the same type”表达式是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63820715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com