-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested_class.cpp
More file actions
executable file
·41 lines (30 loc) · 964 Bytes
/
Copy pathnested_class.cpp
File metadata and controls
executable file
·41 lines (30 loc) · 964 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
39
40
41
#include <iostream>
class Person {
std::string m_Name;
public:
class Address {
std::string m_Country;
std::string m_Division;
std::string m_District;
public:
Address(const std::string& country, const std::string& division, const std::string& district)
: m_Country(country), m_Division(division), m_District(district) {}
void setCountry(const std::string& country) {
m_Country = country;
}
void setDivision(const std::string& division) {
m_Division = division;
}
void setDistrict(const std::string& district) {
m_District = district;
}
};
Address address;
public:
Person(const std::string& name) : m_Name(name), address("", "", "") {}
};
int main() {
Person p("Asraful");
p.address = Person::Address("Bangladesh", "Dhaka", "Madaripur");
return 0;
}