class Processes { public function process1() { echo 'process 1 is completed'; } public function process2() { echo 'process 2 is completed'; } } class ChildProcess extends Processes { public function process3() { echo 'process 3 is completed'; } } $process = new Processes(); $process->process1(); // output is process 1 is completed $process->process2(); // output is process 2 is completed // access parent class methods $cprocess = new ChildProcess(); $cprocess->process1(); // output is process 1 is completed $cprocess->process2(); // output is process 2 is completed $cprocess->process3(); // output is process 3 is completed
In the above example we have a class Processes with two methods the class ChildProcess extends the Processes class. suppose we want to complete a task that should 3 process levels then using inheritance, not necessary to define already defined process1, process2. directly we can extend a parent class and create a child one. Inheritance is very helpful to reduce code duplicating. Inheritance is very simple to use and yet powerfull.
Sands Casino & Resort Spa, Las Vegas - SeptCasino.com
ReplyDeleteAs a febcasino hotel and 샌즈카지노 casino, Sands Casino & Resort Spa has a number of 인카지노 amenities and amenities to keep your Las Vegas entertained!