[好奇] 如何用C做出繼承概念?

看板C_and_CPP作者 (市井小民)時間15年前 (2010/06/17 00:44), 編輯推噓1(105)
留言6則, 5人參與, 最新討論串1/2 (看更多)
原本class裡的成員和函式 比方說有兩個class PHP或java 以php來看的話 class bird { $leg=2; function fly (){ echo "fly"; } } class eagle extends bird { $wing=2; function fastfly(){ echo "fast"; } } 目前想到是用struct把member存起來 function複製並放到外面 struct bird { leg=2; }; struct eaglebird { leg=2; wing=2; } void fly () ; void eaglefly(); void fastfly() ; 可是這樣複製了函式 class一多就麻煩了 大家覺得呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.45.78

06/17 01:04, , 1F
inside the C++ object model
06/17 01:04, 1F


06/17 07:41, , 3F
網址太長打不進去請手動補上 oopc.hmtl
06/17 07:41, 3F

06/17 08:45, , 4F
html 幫改
06/17 08:45, 4F

06/17 15:31, , 5F
06/17 15:31, 5F

06/17 22:46, , 6F
上面縮錯網址了 http://tinyurl.com/f6279
06/17 22:46, 6F
文章代碼(AID): #1C6FzpDF (C_and_CPP)
文章代碼(AID): #1C6FzpDF (C_and_CPP)