<?php
#多态
abstract class tiger{
public abstract function climb();
}
class xtiger extends tiger{
public function climb(){
echo "摔下来;";
}
}
class mtiger extends tiger{
public function climb(){
echo "爬到树顶;";
}
}
class cat {
public function climb(){
echo "飞到天上";
}
}
class client{
public static function call(tiger $animal){
$animal->climb();
}
}
client::call(new xtiger());
client::call(new mtiger());
client::call(new cat());#Catchable fatal error
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/articles/8681435.html