//
異質鍊錶
,清翔兔
06,jan.
#include
#include
using namespace std;
class data_rec
data_rec(int id,string n,int d,bool s):id(id),name(n),date(d),***(s){}
virtual void print()
};class student:public data_rec
void print()
};class staff:public data_rec
void print()
};class teacher:public data_rec
void print()
};class listitem
data_rec* item;
listitem *next; };
class schoollist
void print();
void insert(data_rec*);
void remove(int); };
void schoollist::print() }
void schoollist::insert(data_rec* pn) }
void schoollist::remove(int id)
else
else
} }
}void main()
異質鍊錶的實現
一 目標實現乙個鍊錶,其中的元素型別可以不同。二 思路 思路一 在結點中用共用體儲存資料,用 void 指標指向下乙個結點,並且在結點中記錄本結點的資料型別。0000 enum type 0001 struct node value 0008 void next 0009 鍊錶的每乙個元素其實還都是...
C 異質鍊錶問題,希望有大佬幫忙改下bug
include include using namespace std class person person char name,char int age,char idnumber age age next null 純虛函式 virtual void addnode 0 將物件新增進鍊表,變成...
鍊錶C 實現
node.h 第乙個檔案 ifndef node h define node h define true 1 define false 0 define ok 1 define error 0 define null 0 define flag 1 class node endif node h l...