create a child class of an instantiated class

Enau
121

I have a parent class

Parent_class

and I create an instance

 Parent_class MY_OWN_Parent_class;


So far so good. i want a child class

 

Child_of_MY_OWN_Parent_class : public MY_OWN_Parent_class

of '' MY_OWN_Parent_class '' instead of creating a child class of '' Parent_class "  and then somehow linking it to " MY_OWN_Parent_class ".


is this possible ?

Alexandre Borela
13325
Enau:

I have a parent class

and I create an instance


So far so good. i want a child class

 

of '' MY_OWN_Parent_class '' instead of creating a child class of '' Parent_class "  and then somehow linking it to " MY_OWN_Parent_class ".


is this possible ?

Not possible, you cannot inherit from instances. You would need to create a class for the child and inherit the parent one.

What's the use case? Maybe there's a better solution.
Enau
121
Enau  
Ok thanks. I think my case is too tedious to describe and i have way to get what i want, but it's way longer than just inheriting from an instance.
Dominik Christian Egert
1638
What would be a use case for inheriting from an instance? You inherit from a definition.

Is there a language that supports inheritance from an instance? And why would that be useful?