用vc6.0写的程序 运行不了 不知道哪里错了
#include<iostream.h>#include<string.h>
#include<conio.h>
class person
{
friend class list;
protected:
char name[20];
int age;
char add[40];
char tele[15];
static person *ptr;
person *nest;
public:
preson (char *,int, char, char*);
virtual void printf();
virtual void inset()=0;
};
class student:public person
{
friend class list;
int level;
float great_point_average;
public:
student(char *,int,char *,int,float);
void print();
void inset();
};
class teacher:public person
{
friend class list;
float salary;
public:
teacher(char *,int,char*,char *,float);
void print();
void insert();
};
class staff:public person
{
friend class list;
float hourly_wages;
public:
staff(char *,int ,char*,char*,float);
void print();
void insert();
};
class list
{
person *root;
public:
list()
{root=0;};
void insert_person(person *node);
void remove(char *name);
void print_list();
};
person::person(char *name,int age, char *add, char *tele)
{
strcpy(person::name,name);
strcpy(person::add,add);
strcpy(person::tele,tele);
person::age=age;
next=0;
};
void person::print()
{
cout<<"\nname:"<<name<<"\n";
cout<<"age:"<<age<<"\n";
cout<<"address:"<<add<<"\n";
cout<<"telehone"<<tele<<"\n";
}
student::student(char*name,int age,char*add,int *tele,int level,float grade_point_average):person(name,age,add,tele)
{
student::level=level;
student::great_point_average=great_point_average;
}
void student::insert()
{
ptr=new student(name,age,add,tele,level,grade_point_average);
};
teacher::teacher(char*name,int age,char *add,char*tele,float salary):person(name,age,add,tele)
{
teacher::salary=salary;
}
void teacher::print()
{
person::print();
cout<<"salary:"<<salary<<"\n";
}
void teacher::insert()
{
ptr=new teacher(name,age,add,tele,salary);
}
staff::staff(chae*name,int age,char*add,char*tele,float hourly_wages):person(name,age,add,tele)
{
staff::hourly_wages=hourly_wages;
}
void staff::print()
{person::print();
cout<<"hourly_wages:"<<hourly_wages<<"\n";
}
void staff::insert()
{
ptr=new staff(name,age,add,tele,hourly_wages);
}
void list::insert_peoson(person*node)
{
char key[20];
strcpy(key,node->name);
person *curr_node=root;
person *pervious=0;
while(curr_node!=0&&strcmp(curr_node->name,key)<0)
{
previous=curr_node;
curr_node=curr_node->inset
}
node->insert();
node->ptr->next=curr_node;
if(previous==0)
root==node_ptr;
else
previous->next=node->ptr;
}
void list::remove(char*name)
{
person *curr_node=root;
person *previous=0;
while(curr_node!=0&&strcmp(curr_node->name,name)!=0)
{
previous=curr_node;
curr_node=curr_node->next;
}
if(curr_node!=0&&previous==0)
{
root=curr_node->next;
delete curr_node;
}
else if(curr_node!=0&&previous!=0)
{
previous->next=curr_node->next;
delete curr_node;
}
}
void list::print_list()
{
person *cur=root;
while(cur!=0)
{
cur->printf();
cur=cur->next;
}
}
person *person::ptr=0;
void main()
{
list people;
student stu("wangchong",20,"shanghai","02455524",3,54);
teacher tea("liling",43,"bejing","01063716193",563);
staff sta("chengling",42,"012-65109037",20);
people.insert_person(&stu);
people.insert_person(&tea);
people.insert_person(&sta);
people.print_list();
cout<<endl<<"删除"<<endl;
people.remove("chengling");
people.remove("lining");
people.remove("wangchong");
people.print_list()
}