下载此文档

C 实验多态性.docx


文档分类:IT计算机 | 页数:约5页 举报非法文档有奖
1/5
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/5 下载此文档
文档列表 文档介绍
姓名
学号
班级
年级
指导教师王浩鸣
西安财经学院信息学院
《面向对象程序设计》实验报告
实验名称实验一:多态性实验室学校机房实验日期
实验目的及要求




实验环境
DEV-C++
三、实验内容
#include<iostream>
using namespace std;
class Employee{
private:
string name;
int ID;
public:
Employee(string a,int i){
name=a;
ID=i;
}
~Employee(){

}
void setname(string a){
name=a;
}
void setID(int i){
ID=i;
}
string getname(){

return name;
}
int getID(){

return ID;
}
virtual int getsalary()=0;
virtual void getshow()=0;
};
class Manager:public Employee{
private:
int salary;
public:
Manager(string a,int i,int s):Employee(a,i){
salary=s;
}
~Manager(){
}
void setsalary(int s){
salary=s;
}

void getshow(){
cout<<"姓名为:"<<Employee::getname()<<endl;
cout<<"员工编号为"<<Employee::getID()<<endl;
cout<<"经理"<<endl;

}
int getsalary(){
cout<<"月薪为:"<<salary<<endl;
}

};
class Technician:public Employee{
private:
int wage;
int hours;
public:
Technician(string a,int i,int w,int h):Employee(a,i){
wage=w;
hours=h;
}
~Technician(){
}
void setwage(int w){
wage=w;
}
void sethours(int h){
hours=h;
}
void getshow(){
cout<<"姓名为:"<<Employee::getname()<<endl;
cout<<"员工编号为"<<Employee::getID()<<endl;
cout<<"技术人员"<<endl;

}
int getsalary( ){
int s;
s=wage*hour

C 实验多态性 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数5
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xunlai783
  • 文件大小38 KB
  • 时间2018-01-04