Say I have a struct as shown below:
struct ParentStruct { virtual void XYZ() { getSize(sizeof(*this)); } int memberX; }
And another struct that inherits the parent structure:
struct ChildStruct : public ParentStruct { int memberY; int memberZ; }
Assuming sizeof(int) == 4 , is it possible to have a value of 12 passed to getSize() when called from a child structure (currently I get a value of 4)?
I would prefer not to overwrite XYZ() in all substructures as I will have many of them.
source share