inheritance hierarchy question

liunx

Guest
This question has to deal with class inheritance greater than 2 levels. Consider you have the following:

class A
{
function doSomething() { echo "I'm in class A"; }
}

class B extends A
{
function doSomething() { echo "I'm in class B"; }
}

class C extends B
{
// doSomething is not declared
}

which parent class gets called when I call the following :

$c = new C();
$c->doSomething();Try it and you will see. You have already most of the code, so it would not be any problem to try.If a class does not define a method, it will look in the parent class for the definition. If it is not defined, it will look in the parent class' parent class. And so on and so forth...
 
Back
Top