On Sun, 22 Nov 2015 15:09:34 +0000
Edward Bartolo <edbarx@???> wrote:
> Yes, of course, C structures can be declared that way, but the fact
> remains that the contents of the ancestor's structure are not merged
> into the heir. This means, to access a member N ancestors deep, one
> has to specify all of them in the correct order.
Hi Edward,
I haven't actually done it, but I'm pretty sure the outer struct can
contain function pointers that act as "methods", and that those
"methods" can be the ones that access N ancestors (really subcomponents)
deep. But if the "methods" are written right, the person just *using*
the struct needn't know about that struct's subcomponents.
> The purpose of
> inheritance is to avoid this requirement and to make objects behave in
> a polymorphic way without actually specifying or assigning any virtual
> methods used.
I'm pretty sure you could simulate polymorphism with logic that sets
the struct's actual function pointer methods, but IMHO the mess that
creates would exceed its benefit, kind of like the mess systemd creates
exceeds its benefit.
SteveT
Steve Litt
November 2015 featured book: Troubleshooting Techniques
of the Successful Technologist
http://www.troubleshooters.com/techniques