Day 89 - Why not use Inheritance?

For some reason I can't make a new post in the Code Discussion so I brought this here. Why not use inheritance for the render entries?
Because there is not such thing in C. Inheritance is OOP thingy in C++. Well, you could simulate inheritance in C with structures and function pointer, but it will get ugly very fast (for example look in these files: https://github.com/tracy/AtomixMi....2.4/Source/Core/AtxStreams.h#L32 and https://github.com/tracy/AtomixMi...e/System/Win32/AtxWin32File.c#L36 where Win32FileStream inherits from other "classes").

But if you are actually asking why not use C++ and inheritance, then to that Casey has answered multiple times why he doesn't like C++. Using inheritance would require to deal with constructors, destructors, "new" operator for memory allocation (or object placement) and all the other C++ stuff...

Edited by Mārtiņš Možeiko on
As Casey said Inheritance can make thing more confusing than it should. It's true, Although, I still use it in some cases but, in the past I found what he said to be some what true.

Edited by popcorn on
The answer is because it doesn't actually do anything. The difference between writing

struct clear : public header {...};

and

struct clear {header Header;}

is strictly that you don't type ".Header." in a few places.

As foreshadowed by the TODO I put in there in today's stream, we will be getting read of the header part entirely very shortly - it's an intermediate thing, not a permanent thing.

- Casey