write coments infront of wery line of code.
write coments infront of wery line of code.
#include<iostream>
#include<string>
using namespace std;
class Date
{
public:
Date()
{
month = 1;
day = 1;
year = 1990;
}
Date(int m, int d, int y)
{
month = m;
day = d;
year = y;
}
void set()
{
int d, m, y;
cout << "Enter day: ";
cin >> d;
cout << "Enter month: ";
cin >> m;
cout << "Enter year: ";
cin >> y;
month = m;
day = d;
year = y;
}
void print()
{
cout << day << "-" << month << "-" << year;
}
private:
int month;
int day;
int year;
};
class Parent
{
public:
Parent(string m = "hawa", string f = "adam")
{
mother = m;
father = f;
}
void set()
{
string m; string f;
cout << "Enter mother name: ";
cin >> m;
cout << "Enter father name: ";
cin >> f;
mother = m;
father = f;
}
void print()
{
cout << "father name: " << father << " mother name: " << mother;
}
private:
string mother;
string father;
};
class Employee
{
public:
Employee()
{
ID = 1;
Date d1;
birthdate = d1;
Date d2;
hiredate = d2;
}
Employee(int eID, Date bd, Date hd)
{
ID = eID;
birthdate = bd;
hiredate = hd;
}
void set(Date bd, Date hd, Parent p)
{
int eid;
cout << "Enter ID of Employee: ";
cin >> eid;
ID = eid;
cout << " Enter birth date information" << endl;
bd.set();
birthdate = bd;
cout << " Enter hire date information" << endl;
hd.set();
hiredate = hd;
p.set();
this->p = p;
}
void print()
{
cout << "Employee ID: " << ID
<< " birthDate "; birthdate.print();
cout << " hireDate "; hiredate.print();
cout << " ";
p.print();
cout << endl;
}
private:
int ID;
Date birthdate;
Date hiredate;
Parent p;
};
int main()
{
int e;
cout << "Enter number of emplyees: ";
cin >> e;
Employee e1[10];
Parent p;
Date bd, hd;
for (int i = 0; i < e; i++)
e1[i].set(bd, hd, p);
for (int i = 0; i < e; i++)
e1[i].print();
return 0;
}
Step by step
Solved in 2 steps