Originally Posted by
manasij7479
Aren't those ultimately syntactic sugar for composting (sp?) ...i.e..putting objects of the 'base' (or pointers to them) inside the 'derived' ?
...Some sort of dynamic behavior could easily be attained by maintaining enums or objects (..tables) about the state and nature of a particular object .
Under the hood, there is no difference between composing two classes and having one class inherit from the other. To wit:
Code:
struct Base
{
int a;
};
struct Derived
{
Base base;
int b;
};
The Derived struct is composing two things: a Base and an integer. But imagine that there is some syntactic sugar present, which allows us to avoid needing to put ".base." when we want to reference a member of Base. Suddenly you have inheritance. It's actually no different from composition, but the sugar gives us the feeling that Derived is actually just a specialized form of Base.
Once again, OOP is primarily in your head.