1
#include<iostream>
using namespace std;
template<class T>class Array{
public:
class LinkUnit{
public:
T obj;
LinkUnit *next;
LinkUnit(){
next=NULL;
}
~LinkUnit(){
delete obj;
}
};
private:
LinkUnit *head;//头指针
LinkUnit *GetTial(){
LinkUnit *p;
if(head==NULL)
return NULL;
p=head;
while(p->next!=NULL){
p=p->next;
}
return p;
}
public:
Array(){
head=NULL;
}
void Add(T &obj){
LinkUnit *unit=new LinkUnit();
unit->obj=obj;
if(head==NULL){
head=unit;
return;
}
LinkUnit*p=GetTail();
p->next=unit;
}
T& Get(int index){
if(index==0)
return head->obj;
int n=1;
LinkUnit *head;
while(p->next!==NULL){
if(index==n){
return p->next->obj;
}
p=p->next;
n++;
}
}
void Delete(int index){
if(head==NULL)
return;
LinkUnit *tp;
if(index==0){
*tp=head;
heda=head->next;
delete tp;
return;
}
}
int Size(){
if(head==NULL)
return 0;
int ret=1;
LinkUnit *p;
P=head;
while(p->next!=NULL){
ret++;
p=->next;
}
return ret;
}
};
class Collage{
Public:
strint caption;
void print(){
cout<<caption<<endl;
}
};
int ID0=0l
class Student{
private:
int id;
string name;
string birthday;
Collage collage;
public:
int getID(){
return id;
}
Student (){
Student(string sNmae,stringday,Collage &col){
id=++ID0;
name=sName;
birthday=day;
collage=col;
}
string getNmae(){
return name;
}
string getBirthday(){
return birthday;
}
void printStudent(){
cout<<id<<"\t"<<name<<"\t"<<birthdat<<" "<<collage.caption<<endl;
}
}
};
class StudentList{
private:
Array<Student>studentList;
public:
Student(){
//studentList=
}
void addStudent(string name, string day,Collage &col){
Student *stu=new
Student(name,day,col );
studentList.Add(*stu);
}
void printList(){
cout<<"编号\t姓名\t生日\t学院\n";
for(int i;i<studentList.Size();i++){
studentList.Get(i).printStudent();
}
}
};
class CollageList{
private:
Array<Collage>collageList;
public:
void addCollage(sring caption){
Collage *col=new Collage;
col->caption=caption;
collageList.Add(*col);
}
void printClooage(){
cout<<"学院\n";
for(int i;i<collageList.Size();i++)
collageList.Get(i).print();
}
Collage&getCollage(int index){
return collageList.Get(index);
}
};
int main(int argc,char** argv){
StudentList sList;
CollageList cList;
cList.addCollage("计算机学院");
cList.addCollage("艺术学院");
cList.printClooage();
Collage col1=cList.getCollage(1);
sList.addStudent("A","2001",col1);
sList.addStudent("B","2002",col1);
sList.addStudent("C","2003",col1);
sList.addStudent("D","2004",col1);
sList.addStudent("E","2005",col1);
sList.addStudent("F","2006",col1);
sList.addStudent("G","2007",COL1);
sList.
return 0;
}

浙公网安备 33010602011771号