Question: C++ PLEASE HELP Modify the Person class in Exercise E9.12 so that it contains a pointer to the street address. Construct and display two Person

C++ PLEASE HELPC++ PLEASE HELPModify the Person class in Exercise E9.12 so that itModify the Person class in Exercise E9.12 so that it contains a pointer to the street address. Construct and display two Person objects that share the same StreetAddress object in an executable program.

//Person.cpp

//SOLUTION #include "StreetAddress.h" #include using namespace std;

StreetAddress::StreetAddress() { house_number = 0; street = "None"; city = "None"; state = "None"; postal_code = "00000"; }

StreetAddress::StreetAddress(int h, string st, string c, string s, string pc) { house_number = h; street = st; city = c; state = s; postal_code = pc; }

void StreetAddress::display() const { cout

//Streetaddress.cpp

//SOLUTION #include "StreetAddress.h" #include using namespace std;

StreetAddress::StreetAddress() { house_number = 0; street = "None"; city = "None"; state = "None"; postal_code = "00000"; }

StreetAddress::StreetAddress(int h, string st, string c, string s, string pc) { house_number = h; street = st; city = c; state = s; postal_code = pc; }

void StreetAddress::display() const { cout

//Addresstest.cpp

//SOLUTION #include #include #include "StreetAddress.h" #include "Person.h"

using namespace std;

int main() { StreetAddress address1(1234, "Westover Road NE", "Cedar Rapids", "Iowa", "52403"); StreetAddress address2(31415, "Pi Drive", "Fibonacci", "Nebraska", "11235");

Person person1("Bradjelina Jolipitt", address1); Person person2("Franklin Benjamin", address2);

person1.display(); cout

return 0; }

//person.h

//SOLUTION #ifndef PERSON_H #define PERSON_H #include #include "StreetAddress.h" using namespace std;

/** A class representing a Person. */ class Person { public: Person(string n, StreetAddress sa);

/** Displays the information about the Person. */ void display();

private: string name; StreetAddress address; };

#endif

//Streetaddress.h

//SOLUTION #ifndef PERSON_H #define PERSON_H #include #include "StreetAddress.h" using namespace std;

/** A class representing a Person. */ class Person { public: Person(string n, StreetAddress sa);

/** Displays the information about the Person. */ void display();

private: string name; StreetAddress address; };

#endif

E9.13 Modify the Person class in Exercise E9.12 so that it contains a pointer to the street address. Construct and display two Person objects that share the same StreetAddress object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!