-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.cpp
68 lines (55 loc) · 965 Bytes
/
Person.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Person.cpp
// Mastery_Level2
//
#include "Person.h"
Person::Person(string name, int age)
:saying("Person: I am a person, I can speak")
{
setName(name);
setAge(age);
}
// constructor overloading
Person::Person(string name, int age, string saying)
{
setName(name);
setAge(age);
setSpeak(saying);
}
Person::~Person() {}
// operator overloading
Person Person::operator+ (Person person)
{
Person temp("blank",22," OPERATOR OVERLOAD!");
temp.setSpeak(person.getSpeak()+temp.getSpeak());
return temp;
}
// accessor and mutators
void Person::setName(string name)
{
(this->name) = name;
}
string Person::getName()
{
return(this->name);
}
void Person::setAge(int age)
{
(this->age) = age;
}
int Person::getAge()
{
return (this->age);
}
void Person::speak()
{
cout << getSpeak() << endl;
}
void Person::setSpeak(string saying)
{
(this->saying) = saying;
}
string Person::getSpeak()
{
return (this->saying);
}