For academic purposes, I am wondering if a parent method call should lead to a parent’s parent method call in case when the parent has no such method?
For example (pseudo-code):
class A {
function doSomething() {
}
}
class B extends A {}
class C extends B {
function doSomething() {
parent::doSomething();
}
}
i = new C();
i->doSomething();
Does parent calling in object oriented languages mean that if the parent is missing the method, its parent will have its method called instead?
In OOP this question is usually answered by the function
doSomething‘s visibility.If it was protected or public in class
A, then yes, it will be called if it is not overridden inB(I assume here also that the
extendskeyword is public inheritance. See http://www.learncpp.com/cpp-tutorial/115-inheritance-and-access-specifiers/ for more information.)