父類

class animal{

...

}

 

子類

class bird : animal{

....

}

 

子子類

class Penguin : bird{

....

}

 

 

假設一個分析動物的程式

可以接受animal的物件作為輸入,則也可以接受bird及 penguin

一個分析penguin的程式

可以接受penguin的物件作為輸入,則不可接受animal及bird

arrow
arrow
    全站熱搜

    alansong 發表在 痞客邦 留言(0) 人氣()