Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • Since there are multiple "derived" structs, would the member for the BaseStruct that points to the "derived" struct has to be a template since the BaseStruct has to be able to point to different structs i.e BaseStruct -> StructA, BaseStruct -> StructB ?
    – galaxied
    Commented Oct 29 at 21:07
  • No, you need a new base class for the data to derive from. So you have struct StructA : BaseData {...} etc. Commented Oct 29 at 22:14
  • Isn’t that what is in the example? Struct derivedStruct : public BaseStruct
    – galaxied
    Commented Oct 29 at 22:16
  • "Isn’t that what is in the example?" No. Your example has one level of indirection less. Anyway, don't do that. Just make BaseStruct abstract. That's all you need. Commented Oct 29 at 22:23
  • So there is a virtual deconstructor?
    – galaxied
    Commented Oct 29 at 22:54