I am trying to understand whether the answer to the following question is the same in all the main OOP languages; and if not, how different are these languages.
Suppose I have a class A that defines act and jump methods; The act method calls the jump method. A subclass B overrides the jump method (i.e., the appropriate syntax is used to ensure that the call to implementation is implemented in class B ).
I have an object B class B I want him to behave as if he were class A In other words, I want jump executed using an implementation in A What are my options in different languages?
For example, can I achieve this with some form of contraction? Or perhaps by creating a proxy object that knows which methods to call?
I would like to avoid creating a completely new class A object and carefully set up sharing of the internal state between A and B , because it is clearly not promising and difficult. I would also like to avoid copying state B to a new class A object, because there can be a lot of data to copy.
UPDATE
I asked this question specifically about Python , but it seems that this cannot be achieved in Python , and technically it can be done ... kinda ..
In addition to technical feasibility, there seems to be a strong argument against this in terms of design. I ask about this in a separate question .
source share