You can do it using final modifier before summary() method definition in your parent class.
How to prevent a particular method from overriding?
سؤال
I have a parent class:
class parent{
var $a = 'param1';
var $b = 'param2';
public summary(){
if($this->a<0 || $this->b<0)
return FALSE;
return $this->a+$this->b;
}
public set_null(){
$this->a = null;
$this->a = null;
}
}
I need to prevent the summary method from overriding in child class, maybe my team doesn't know if summary method exists before.
class child extends parent{
public summary(){
return $this->a+$this->b;
}
public set_null(){
$this->a = 0;
$this->b = 0;
}
}
Can anyone help me with this problem?
المحلول
لا تنتمي إلى StackOverflow