Timeline for How to assign values to a base struct that aren't reset when downcasted as shared pointers
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 30 at 21:53 | comment | added | galaxied | Okay, thanks a lot! | |
Oct 30 at 6:55 | comment | added | n. m. could be an AI | Yes a pure virtual destructor should do the job | |
Oct 30 at 1:50 | vote | accept | galaxied | ||
Oct 29 at 22:54 | comment | added | galaxied | So there is a virtual deconstructor? | |
Oct 29 at 22:23 | comment | added | n. m. could be an AI |
"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.
|
|
Oct 29 at 22:16 | comment | added | galaxied |
Isn’t that what is in the example? Struct derivedStruct : public BaseStruct
|
|
Oct 29 at 22:14 | comment | added | n. m. could be an AI |
No, you need a new base class for the data to derive from. So you have struct StructA : BaseData {...} etc.
|
|
Oct 29 at 21:07 | comment | added | galaxied |
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 ?
|
|
Oct 29 at 5:20 | history | answered | n. m. could be an AI | CC BY-SA 4.0 |