| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 506 人关注过本帖
标题:老是链接失败
只看楼主 加入收藏
djy5043
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2007-5-9
收藏
 问题点数:0 回复次数:1 
老是链接失败
现在编译没有错误老是链接有错误
大家能不能详细解释一下
我是没有编程基础才学几天的新手
谢谢
//编写一个用于院校人事管理的程序,要求能够输入、显示各类人员的信息。
//假设院校有四类人员:学生,教师,员工和在职进修教师,他们都有姓名,性别、电话等共同信息
//学生具有年级、专业课程和各科成绩的信息,员工具有所在部门、工资的信息
//教师具有所在部门、工资和所授课程的信息,在职进修教师兼有教师和学生两类信息
#include<iostream>
#include<string>
using namespace std;
class College_person{
protected:
    string name;
    string sex;
    int phone;
    string duty;
public:
    College_person(string tempduty="学生"):duty(tempduty)
    {
        cout<<duty<<endl;
        cout<<"姓名:";
        cin>>name;
        cout<<"性别:";
        cin>>sex;
        cout<<"电话:";
        cin>>phone;
    }
    void display()
    {
        cout<<"职务:"<<duty<<"  姓名:"<<name<<"  性别:"<<sex<<"  电话:"<<phone<<endl;
    }
};
class Student:public College_person{
protected:
    int grade;
    string study_class[3];
    int score[3];
    int i;
public:
    Student():College_person("学生")
    {
        cout<<"年级:";
        cin>>grade;
        cout<<"专业课程:";
        for(i=0;i<3;i++)
        cin>>study_class[i];
        cout<<"各科成绩:";
        for(i=0;i<3;i++)
        cin>>score[i];
    }
    void show()
    {
        College_person::display();
        cout<<"年级:"<<grade<<"  专业课程:";
        for(i=0;i<3;i++)
        cout<<study_class[i]<<"  ";
        cout<<"  各科成绩:  ";
        for(i=0;i<3;i++)
        cout<<score[i]<<"  ";
        cout<<endl;
    }
};
class Workers:virtual public College_person{
protected:
    string department;
    float salary;
public:
    Workers():College_person("员工")
    {
        cout<<"部门:";
        cin>>department;
        cout<<"工资:";
        cin>>salary;
    }
    void show()
    {
        College_person::display();
        cout<<"部门:"<<department<<"  工资:"<<salary;
        cout<<endl;
    }
};
class Teachers:public Workers{
protected:
    int i;
    string teach_class[3];
public:
    Teachers():Workers(),College_person("教师")
    {
        cout<<"所授课程:";
        for(i=0;i<3;i++)
        cin>>teach_class[i];
    }
    void show()
    {
        Workers::show();
        cout<<"  所授课程:";
        for(i=0;i<3;i++)
        cout<<teach_class[i]<<"  ";
        cout<<endl;
    }
};
class Advanced_teacher:public Student,public Teachers{
public:
    int i;
    Advanced_teacher():Student(),Teachers(),College_person("在职进修教师")
    {}
    void show()
    {
        Student::show();
        Teachers::show();
    }
};
void main()
{
    Student a;
    a.show();
    Workers b;
    b.show();
    Teachers c;
    c.show();
    Advanced_teacher d;
    d.show();
}
搜索更多相关主题的帖子: 失败 链接 
2008-04-21 22:05
djy5043
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2007-5-9
收藏
得分:0 
我还想问一个问题啊
当定义一个派生类对象时
系统会不会调用间接基类的构造函数

如果是多继承的话
这个派生类,直接基类,间接基类的构造函数调用又是怎么调用的呢
2008-04-22 09:03
快速回复:老是链接失败
数据加载中...
 
   



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

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