abstractclassA{private$name;function__construct($param){$this->name='liming'.'';}functiongetName(){echo$this->name;}//調用子類中的方法getAge2functiongetAge(){$this->getAge2();}functiongetAge3(){return'23';}}classBextendsA{functiongetAge2(){echo$this->getAge3();}}$a=newB('a');$a->getName();$a->getAge();
為什么父類中可以調用子類的方法?
慕田峪9158850
2019-03-30 11:37:58