the following example and write a comment after each line of code. In result print output of code. #include #include using namespace std;   class Date { public: Date() { month = 1; day = 1; year = 1990;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 Execute the following example and write a comment after each line of code. In result print output 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;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education