Firstly I'm extending an existing class structure and cannot alter the original, with that caveat:
I would like to do this:
class a
{
int val;
... // usual constructor, etc...
public int displayAlteredValue(int inp)
{
return (val*inp);
}
}
class b extends a
{
... // usual constructor, etc...
public in displayAlteredValue(int inp1, int inp2)
{
return (val*inp1*inp2);
}
}
As I said before I cannot alter class a
and I want to maintain the function name displayAlteredValue
rather than making a new function.
If this can be done I only have to change a few instantiations of a
to instantiations of b
. I don't want to spend a lot of time replacing the many function calls to displayAlteredValue
. (And yes I do realise there are such things as search and replace however for other reasons, doing that would be problematic).
Any ideas?