-
Notifications
You must be signed in to change notification settings - Fork 0
/
Composition101.cpp
49 lines (42 loc) · 1.08 KB
/
Composition101.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
43
44
45
46
47
48
49
// Last sanity check: 2020-05-18
// Example program
#include <iostream>
#include <string>
using namespace std;
class Birthday
{
int month, day, year;
public:
Birthday(int m, int d, int y) : month(m), day(d), year(y)
{ cout<<"New birthday created: "<<month<<"/"<<day<<"/"<<year<<endl; };
~Birthday() { cout <<"Deleted Birthday object " <<month<<"/"<<day<<"/"<<year<< endl; }
void printDate()
{
cout<<month<<"/"<<day<<"/"<<year<<endl;
}
};
class People
{
string name;
Birthday dateOfBirth;
public:
People(string x, Birthday b) : name(x), dateOfBirth(b)
{
cout << "New people created: " << name << endl;
}
~People() { cout<< "Deleted People object "<< name<< endl; }
void printInfo()
{
cout << name << " was born on ";
dateOfBirth.printDate();
cout << endl;
}
};
int main()
{
Birthday birthAlex = Birthday(03, 11, 1994);
People alex = People("Alex Seceleanu", birthAlex);
//alex.printInfo();
cout << endl <<"END OF PROGRAM"<<endl;
return 0;
}