Contiguous storage of polymorphic types
问题 I'm interested to know if there is any viable way to contiguously store an array of polymorphic objects, such that virtual methods on a common base can be legally called (and would dispatch to the correct overridden method in a subclass). For example, considering the following classes: struct B { int common; int getCommon() { return common; } virtual int getVirtual() const = 0; } struct D1 : B { virtual int getVirtual final const { return 5 }; } struct D2 : B { int d2int; virtual int