Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a class person with the following fields: The name A pointer to the pe

ID: 3624079 • Letter: I

Question

Implement a class person with the following fields:
The name
A pointer to the person's best friend
A popularity counter that indicates how many other people have this person as their best friend.

The program reads in a list of names, allocates a new person for each of them, and stores them in a vector<Person*>. 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, best friend, and popularity counter for each.

Explanation / Answer

Your class person will look like this:


class Person

{

String name;

String* best_friend;

int pop_counter;

}


You can now simply create a vector of Person and store the details like this:


loop

{

//take input name;

Add the name in the persons vector

}


Cheers!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote