在下面的代碼中,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