Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class address {
- private:
- string country, region, district, locality, street, building;
- int apartment, room;
- public:
- address();
- address(const string&, const string, const string, const string, const string,
- const string, int, int);
- address(const address&);
- ~address();
- address& operator=(address a);
- void setData();
- friend bool operator == (const address&, const address&);
- void print();
- };
- void address::setData() {
- cout << "country=";
- cin >> this->country;
- cout << "region=";
- cin >> this->region;
- cout << "district=";
- cin >> this->district;
- cout << "locality=";
- cin >> this->locality;
- cout << "street=";
- cin >> this->street;
- cout << "building=";
- cin >> this->building;
- cout << "apartment";
- cin >> this->apartment;
- cout << "room";
- cin >> this->room;
- }
- address::address() {
- country = "";
- region = "";
- district = "";
- locality = "";
- street = "";
- building = "";
- apartment = 0;
- room = 0;
- }
- address::address(const string& country, const string region, const string district, const
- string locality, const string street, const string building, int apartment, int room) {
- this->country = country;
- this->region = region;
- this->district = district;
- this->locality = locality;
- this->street = street;
- this->building = building;
- this->apartment = apartment;
- this->room = room;
- }
- address::~address() {
- }
- address::address(const address& _address) {
- country = _address.country;
- region = _address.region;
- district = _address.district;
- locality = _address.locality;
- street = _address.street;
- building = _address.building;
- apartment = _address.apartment;
- room = _address.room;
- }
- address& address::operator=(address a) {
- this->country = a.country;
- this->region = a.region;
- this->district = a.district;
- this->locality = a.locality;
- this->street = a.street;
- this->building = a.building;
- this->apartment = a.apartment;
- this->room = a.room;
- return *this;
- }
- bool operator == (const address &d1,const address &d2) {
- if (d1.country == d2.country && d1.region == d2.region && d1.district ==
- d2.district && d1.locality == d2.locality && d1.street == d2.street && d1.building ==
- d2.building && d1.apartment == d2.apartment && d1.room == d2.room)
- {
- cout << true << endl;
- return true;
- }
- else
- {
- cout << false << endl;
- return false;
- }
- }
- void address::print() {
- cout << this->country << " " << this->region << " "<< this->district<< " " << this->locality << " "<< this->street << " " << this->building <<" "<< this->apartment << " " << this->room << endl;
- }
- int main() {
- int n;
- cout << "Enter the mas size: " << endl;
- cin >> n;
- address* mas = new address[n];
- for (int i = 0; i < n; i++)
- {
- mas[i].setData();
- }
- address r = mas[0];
- address q("Russia", "Kursk", "Kursk", "Center", "Alal", "Apartment", 2, 3);
- q.print();
- cout << endl;
- for (int i = 0; i < n; i++)
- {
- mas[i].print();
- }
- bool result = r == q;
- delete[] mas;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement