On 14.12.2019 2:44, Sam wrote:
> fir writes:
>
>
>> what you need to desctibe it and make it searchable. accesible is
>> rather a tag, then you may and its ok to do give some relations to
>> this tags itself but those tahs like are by nature multidimensional
>> and cross itself i mean
>
> I could not make any heads or tails of this stream of consciousness, in
> the surrounding paragraphs. Whatever you're suffering from, I hope you
> feel better someday.
I suspect he might have just discovered that one can classify things in
different ways. And by some reason he thinks this is somehow relevant
for C++ inheritance, probably because his only knowledge of C++ comes
from a crappy tutorial which had some silly animal-dog-duck example.
In C++ inheritance is a special coding technique which might be useful
in some specific scenarios (btw, classification of things is not such a
scenario), but it's just one tool among many.
I find it ironic that while OP finds C language superior because it does
not have inheritance, my last usage of inheritance was directly related
to a C program (Python). I coded a Python extension module defining an
extension Python type. The Python manuals say that an extension Python
type must be defined by a struct which has the "base class" PyObject in
the beginning. There are some nifty macros for doing that:
typedef struct {
PyObject_HEAD
/* Type-specific fields go here. */
} CustomObject;
which expands to
typedef struct {
PyObject ob_base;
/* Type-specific fields go here. */
} CustomObject;
However, doing it this way would mean to litter my code with nasty
reinterpret_casts because the PyObject and CustomObject are unrelated
types, but one needs to cast between pointers to them at every step. So
I used C++ inheritance instead:
struct CustomObject : PyObject {
/* Type-specific fields go here. */
};
Voila! No cast to PyObject needed any more, and a well-defined
static_cast instead of error-prone reinterpret_cast in the other direction.
I guess the bottom line is that languages lacking inheritance are bound
to reinvent it in ugly ways.