Professional Documents
Culture Documents
#include <string>
using namespace std;
class Date{
private:
int month;
int day;
int year;
friend void print();
public:
Date(int m,int d,int y){
if(d>0 || d<=31){
day = d;
}
if(m>0 || m<=12){
month = m;
}
if(y>=1900){
year = y;
}
}
void setDate(int m,int d,int y){
if(d>0 || d<=31){
day = d;
}
if(m>0 || m<=12){
month = m;
}
if(y>=1900){
year = y;
}}
Date(){month = 1;
year = 1900;
day = 1;
}
int getDay() const
{
return day;
}
int getMonth() const
{
return month;
}
int getYear() const
{
return year;
}
void setDay(int day)
{
if(day>0 || day<=31)
this->day = day;
}
void setMonth(int month)
{
if(month>0 || month<=31)
this->month = month;
}
void setYear(int year)
{
if(year>1900)
this->year = year;
}
void printDate(){
cout<<year<<"/";
if(month>9){
cout<<month<<"/";
}else{
cout<<"0"<<month<<"/";
}
if(day>9){
cout<<day;
}else{
cout<<"0"<<day;
}}};
#include<iostream>
#include<string.h>
#include"date.h"
class Employee{
protected:
char firstname[25];
char lastname[25];
Date birthDate;
Date hireDate;
public:
strcpy(firstname,first);
strcpy(lastname,last);
birthDate=Bday;
hireDate=Hday;
void print(){
cout<<"Name the employee is "<<firstname<<" "<<lastname<<endl;
birthDate.printDate();
cout<<endl;
hireDate.printDate();
cout<<endl;
};
#include<iostream>
#include<string.h>
#include"employee.h"
using namespace std;
int main(){
Date birth(7,24,1949);
Date hire(3,12,1988);
Employee manager("bob","blue",birth,hire);
manager.print();
return 0;
}