用多态性实现工资发放系统 源代码

更新时间:2023-06-02 19:12:00 阅读: 评论:0

#ifndef HEADER_KESHE1
#define HEADER_KESHE1
class Birthdate
{
    unsigned year,month;
public:
    Birthdate(unsigned=1900,unsigned=01);
    void SetYear(unsigned);
    void SetMonth(unsigned);
    unsigned GetYear() const;
    unsigned GetMonth() const;
    friend ostream& operator<<(ostream& out, Birthdate& b){
        return out<<tw(6)<< b.year << '/' << tw(2) <<tfill('0')<< b.month;
    }
    friend istream& operator>>(istream& in,Birthdate& b){
    string buf;
    in >> buf;
    b.SetYear(atoi(buf.substr(0,4).c_str()));
    b.SetMonth(atoi(buf.substr(5,2).c_str()));
    return in;
    }
    friend ofstream& operator<<(ofstream& fout, Birthdate& b){
    fout <<tfill(' ')<<b.GetYear() << '/';
    fout <<tw(2)<<tfill('0')<<b.GetMonth()<<tfill(' ');
    return fout;
通讯录同步    }
    friend ifstream& operator>>(ifstream& fin,Birthdate& b){
    string buf;
    fin >> buf;
    b.SetYear(atoi(buf.substr(0,4).c_str()));
科学养牛
    b.SetMonth(atoi(buf.substr(5,2).c_str()));
    return fin;
    }
};
#endif
#include<string>
#include<iomanip>
#include<fstream>
#include<iostream>
陈文述using namespace std;
#include"keshe1.h"
Birthdate::Birthdate(unsigned y,unsigned m){
    year=y;
    month=m;
}
void Birthdate::SetYear(unsigned y)
{
    year=y;
}
void Birthdate::SetMonth(unsigned m){
    month=m;
}
unsigned Birthdate::GetYear()const{
    return year;
}
unsigned Birthdate::GetMonth()const{
    return month;
}
#ifndef HEADER_KESHE2
#define HEADER_KESHE2
#include"keshe1.h"
class Employee{           
    unsigned ID;
    string name;
    Birthdate bir;
    string type;
    bool reward;       
    bool draw;         
public:
    Employee(unsigned i,string,Birthdate,string);
    Employee(Employee& );
    void SetName(string);
    void SetBirth(unsigned,欧式油画unsigned);
    void SetBirth(Birthdate b);
月经期能喝中药吗    void SetType(string);
    void SetReward(bool);
    void心情不好的诗句 SetDraw(bool);
    void SetID(unsigned);
    unsigned GetId() const;
    string GetName() const;
    Birthdate GetBirthday() const;
    string GetType() const;
    bool GetReward(unsigned) const;
    bool GetDraw() const;
    virtual double Pay() const {return 0;};           
    virtual void Display() ;                     
    virtual void writeoffile(ofstream& fout) ;         
};
#endif
#include<string>
#include<iomanip>
#include<fstream>
#include<iostream>
using namespace std;
#include"keshe2.h"
Employee::Employee(unsigned i,string n,Birthdate b,string t):bir(b){
    ID=i;
    name=n;
    type=t;
    reward=0;
    draw=0;
}
Employee::Employee(Employee& e){
    ID=e.ID;
    name=e.name;
    pe;毕业歌曲
    ward;
    draw=e.draw;
    bir=e.bir;
}
void Employee::SetName(string n){
    name=n;
}
void Employee::SetBirth(unsigned y,unsigned m){
    bir.SetYear(y);
    bir.SetMonth(m);
}
void Employee::SetBirth(Birthdate b){
    bir=b;
}
void Employee::SetType(string t){
    type=t;
}
void Employee::SetReward(bool r){
    reward=r;
}
void Employee::SetDraw(bool d){
    draw=d;
}
void Employee::SetID(unsigned id){
    ID=id;
}
unsigned Employee::GetId()const{
    return ID;
}
string Employee::GetName()const{
    return name;
}
Birthdate Employee::GetBirthday()const{
    return bir;
}
string Employee::GetType()const{
    return type;
}
bool Employee::GetReward(unsigned m)const{
    if(m==bir.GetMonth())
        return 1;
    return reward;
}
bool Employee::GetDraw()const{
    return draw;
}
void Employee::Display(){
    cout<<tfill('0')<<tw(6)<<ID;
    cout<<tfill(' ')<<tw(6)<<name<<tw(7)<<bir.GetYear()<<"/"<<tw(2)<<bir.GetMonth()<<tw(6)<<type<<tw(10);
}
void Employee::writeoffile(ofstream& fout){
    fout<<tfill('0')<<tw(6)<<ID<<" ";
    fout<<tfill(' ')<<name<<tw(8)<<bir.GetYear()<<" "<<bir.GetMonth()<<tw(8)<<type<<tw(8)<<draw<<tw(8);
}
#ifndef HEADER_KESHE3
#define HEADER_KESHE3
#include"keshe2.h"
class SalariedEmployee:virtual public Employee{     
    int leaveday; 
    double salary; 
public:
    SalariedEmployee(unsigned ,string,Birthdate,string,int,double);
    SalariedEmployee(Employee& ,int ,double);
    void SetLeaveDay(int);
    void SetSalary(double);
    int GetLeaveDay() const;
    double GetSalary() const;
    virtual double Pay() const;           
    virtual void Display() ;     
    virtual void writeoffile(ofstream& fout) ; 
};
#endif
#include<string>
#include<fstream>
皮肤暗黄怎么调理#include<iomanip>
#include<iostream>
#include<windows.h>
using namespace std;
#include"keshe3.h"
SalariedEmployee::SalariedEmployee(unsigned i,string n,Birthdate b,string t,int l=0,double s=3000):Employee(i,n,b,t){
    leaveday=l;
    salary=s;
}
SalariedEmployee::SalariedEmployee(Employee& e,int l,double s ):Employee(e){

本文发布于:2023-06-02 19:12:00,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/968348.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:油画   月经期   诗句   毕业
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图