标签:style blog color cti io div
小孩和公共设施
用继承的方法:
class Sanitation{ public function Washhands(){ echo "Cleaning!"; } } class Child extends Sanitation{ } $child=new Child(); $child->Washhands();
委托关系:
class Sanitation{ public function Washhands(){ echo "Cleaning!"; } } class Child { private $sanitation; function __construct(){ $this->sanitation=new Sanitation(); } public function Washhands(){ return $this->sanitation->Washhands(); } } $child=new Child(); $child->Washhands();
标签:style blog color cti io div
原文地址:http://www.cnblogs.com/canbefree/p/3835053.html