-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.cpp
More file actions
38 lines (37 loc) · 740 Bytes
/
Person.cpp
File metadata and controls
38 lines (37 loc) · 740 Bytes
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
#include "Person.h"
Person::Person() {
name = nullptr;
id = 0;
}
Person::Person(char* n, long int i) {
id = i;
name = nullptr;
copyArray(n, name);
}
Person::Person(const Person& other) {
id = other.id;
name = nullptr;
if (other.name) {
copyArray(other.name, name);
}
}
Person& Person::operator=(const Person& other) {
if (this != &other) {
delete[] name;
name = nullptr;
id = other.id;
if (other.name) {
copyArray(other.name, name);
}
}
return *this;
}
Person::~Person() {
delete[] name;
}
char* Person::getName() const {
return name;
}
long int Person::getId() const {
return id;
}