4 ms·
The Linux Kernel codebase is full of inheritance, if you are open to understand how inheritance gets implemented in plain C. A graphics driver for a certain ve
by dyingkneepad 6y ago
The Linux Kernel codebase is full of inheritance, if you are open to understand how inheritance gets implemented in plain C.
A graphics driver for a certain vendor inherits from the DRM class, which inherits from PCI, which inherits from the Device class. Structs which embeds structs which embed structs, and you can access the base classes using the container_of() macro.
As for me, I particularly abuse inheritance in C++, although I a lot of cases I end up replacing it with template programming. To the luck of society, most of the code where I abuse templates and inheritance is not used by anybody else except for me.
- mwhite 6y agoIsn't structs which embed structs composition, not inheritance?