Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 HELPimage text in transcribedModify 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

10. Why is it important to check cultural generalizations? (LO 7-7)

Answered: 1 week ago

Question

How would we like to see ourselves?

Answered: 1 week ago