java - Call parent method instead of the overriden one -
i have class c1
:
public class c1 { public void method() { //do } protected void anothermethod() { if (something) { method(); /*here, want call method c1.method, * c2.method called */ } } }
and class c2
extends
, overrides
method
:
public class c2 extends c1 { @override public void method() { if (something) { anothermethod(); } else { super.method(); } } }
my problem described in code comment. can't run parent method in parent class. reason?
annoyingly, can't (setting aside reflective hacks).
but on lines
public class c1 { public final void _method() /*rename taste*/{ } public void method(){ _method(); } }
and override method
in derived class. if require base class method, call _method()
. think that's nearest writing c1::method()
permissible in c++.
Comments
Post a Comment