-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq48.cpp
42 lines (39 loc) · 994 Bytes
/
q48.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <stdio.h>
using namespace std;
class DOB {
int year, month, day;
public:
DOB(int year, int month, int day) {
this->day = day;
this->month = month;
this->year = year;
}
void display() {
cout << year << "-" << month << "-" << day << '\n';
}
};
class Employee {
string name;
DOB *birthdate;
public:
Employee(string name, string birth) {
this->name = name;
int year, month, day;
sscanf(birth.c_str(), "%d-%d-%d", &year, &month, &day);
this->birthdate = new DOB(year, month, day);
}
void display() {
cout << "Employee name: " << name << '\n';
cout << "Birthdate: ";
birthdate->display();
}
~Employee() {
delete birthdate;
}
};
int main() {
Employee emp("Mark Hammond", "1990-12-30");
emp.display();
return 0;
}