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 HELPModify 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 objectStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started