forked from buckyroberts/Source-Code-from-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path46_&47_cppBeginners.cpp
More file actions
82 lines (67 loc) · 1.21 KB
/
46_&47_cppBeginners.cpp
File metadata and controls
82 lines (67 loc) · 1.21 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//This is Birthday.h file
#ifndef BIRTHDAY_H
#define BIRTHDAY_H
class Birthday
{
public:
Birthday(int m, int d,int y);
void printDate();
private:
int month;
int day;
int year;
};
#endif // BIRTHDAY_H
//This is Birthday.cpp file
#include "Birthday.h"
#include <iostream>
using namespace std;
Birthday::Birthday(int m, int d, int y)
{
month = m;
day = d;
year = y;
}
void Birthday::printDate(){
cout << month << "/" << day << "/" << year <<endl;
}
//This is People.h file
#ifndef PEOPLE_H
#define PEOPLE_H
#include <string>
#include "Birthday.h"
using namespace std;
class People
{
public:
People(string x,Birthday bo);
void printInfo();
private:
string name;
Birthday dataOfBirth;
};
#endif // PEOPLE_H
//This is People.cpp file
#include "People.h"
#include "Birthday.h"
#include <iostream>
using namespace std;
People::People(String x,Birthday bo)
: name(x), dataOfBirth(bo)
{
}
void People::printInfo(){
cout << name << "was born on";
dataOfBirth.printDate();
}
//This is main.cpp file
#include <iostream>
#include "Birthday.h"
#include "People.h"
using namespace std;
int main()
{
Birthday birthObj(12,28,1986);
People buckyRoberts("Bucky the King",birthObj);
buckyRoberts.printInfo();
}