在下面的代码中,foo
的构造函数调用child1
还是child2
的构造函数?我可以从父类中调用子类的构造函数吗?
class child1 extends foo{
function child1(){
do_stuff();
}
}
class child2 extends foo{
function child2(){
do_stuff();
}
}
class foo{
function foo(){
// run child1, child2 etc... ? is it possible?
}
}
new foo();
反之亦然 - 您可以在扩展类中调用父方法。你究竟想要做什么? – Mikk 2011-05-04 18:25:33