看板 C_and_CPP 關於我們 聯絡資訊
剛剛想到一個類似祖譜的資料結構不知道該怎麼實現 Mary是Judy的媽媽,以此類推 Judy -> Mary -> Alice -> Linda -> Cindy -> Diana Elma Peoplerelationship A; //假設A為Alice cout << A.mother.mother << endl; // Cindy cout << A.daughter(0).mother.daughter(1) <<endl; // Elma 簡單的是像這樣再複雜的話就是又有兄弟姐妹之類的 如A.mother.brother(1).daughter(0) 有人可以起個頭嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.136.220.110 ※ 編輯: smilecylin 來自: 220.136.220.110 (02/18 21:14)
ilway25:傳回一個人的reference? 02/18 22:05
chph:不就樹狀結構嗎? 兩個成員變數一個放名字一個放媽媽 02/18 22:13
chph:再加一個成員變數記錄他的兄姐或弟妹 02/18 22:14
comaniac:struct的tree, 資料結構的書都會有類似的吧 02/18 23:51