Question: The coding language is C++ Implement a class Person with the following fields: - the name - a pointer to the person's best friend (a

The coding language is C++

Implement a class Person with the following fields:

- the name

- a pointer to the person's best friend (a Person*)

- a popularity counter that indicates how many other people have this person as their best friend

Write a program that reads in a list of names, allocates a new Person for each of them, and stores them in a vector. Then ask the name of the best friend for each of the Person objects. Locate the object matching the friend's name and call a set_best_friend member function to update the pointer and counter. Finally, print out all Person objects, listing the name, besr friend, and popularity counter for each.

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!