Question: Consider the following (partial) class declaration of an ADT: class Person { public: Person(); Person(string n, string a); ~Person(); void setAddress(string a); bool checkAddress(string n);

Consider the following (partial) class declaration of an ADT:

class Person

{

public:

Person();

Person(string n, string a);

~Person();

void setAddress(string a);

bool checkAddress(string n);

bool isPerson(string n);

friend istream& operator >> (istream& ins, Person& p);

friend ostream& operator << (ostream& outs, const Person & p);

private:

string name;

string address;

};

Use the appropriate member functions given in the class declaration for the class Person to write statements to do the following:

  • Instantiate an object anne of class Person.
  • Use the overloaded stream extraction operator to read in values to initialize anne from a file People.dat. Assume the file People.dat has been associated with an input stream object infile.
  • Write a statement to check whether the object anne represents Anne Barnard. If so, change annes address to The Castle, Cape Town.
  • Display the values of the member variables in the object anne on the screen, using the overloaded stream insertion operator.
Maximum number of characters (including HTML tags added by text editor): 32,000

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!