-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson Address.cpp
54 lines (50 loc) · 988 Bytes
/
Person Address.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
#include "Address.h"
Address::Address()
{
houseNumber = 0;
city = "";
country = "";
}
Address::Address(int h_n, string cit, string coun){
setHouseNumber(h_n);
setCity(cit);
setCountry(coun);
}
void Address::display(){
cout << "House number: " << houseNumber << endl;
cout << "City: " << city << endl;
cout << "Country: " << country << endl;
}
void Address::setHouseNumber(int h_n){
houseNumber = h_n;
}
void Address::setCity(string c){
int size = 0;
for (int i = 0; c[i] != '\0'; i++)
size++;
city = new char[size + 1];
for (int i = 0; i < size; i++)
city[i] = c[i];
city[size] = '\0';
}
void Address::setCountry(string c){
int size = 0;
for (int i = 0; c[i] != '\0'; i++)
size++;
country = new char[size + 1];
for (int i = 0; i < size; i++)
country[i] = c[i];
country[size] = '\0';
}
int Address::getHouseNumber(){
return houseNumber;
}
string Address::getCity(){
return city;
}
string Address::getCountry(){
return country;
}
Address::~Address()
{
}