| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 637 人关注过本帖
标题:用vc6.0写的程序 运行不了 不知道哪里错了
取消只看楼主 加入收藏
a2696026
Rank: 2
等 级:论坛游民
帖 子:21
专家分:33
注 册:2009-9-9
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
用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()
}
搜索更多相关主题的帖子: 运行 
2009-10-04 15:28
a2696026
Rank: 2
等 级:论坛游民
帖 子:21
专家分:33
注 册:2009-9-9
收藏
得分:0 
回复 2楼 bccnbin2009
行啊  兄弟 我回去运行看看
2009-10-05 15:40
快速回复:用vc6.0写的程序 运行不了 不知道哪里错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.064169 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved