How to override a method in same class?

sares

New member
Joined
May 31, 2010
Messages
1
Programming Experience
Beginner
Let's say there is a class "parent" that has a method "print" and there is an object declared that calls this method.

I want to replace the method "print" without modifying the original code.
I understand that I can declare a new class "child" that inherits from "parent" and override "print".
If I then create a "child" object, it will use the new print method.
But the parent object will be still using it's print method.
So how do I override the print method so that parent will use it? (ie. the print method in the parent class, without declaring a new child class)
Is this even possible?
 
Back
Top