Question: In C++ #ifndef PERSON_H #define PERSON_H #include using namespace std; class Person { string name; Person * best_friend; int popularity; public: Person(): name(), best_friend(0), popularity(0)
In C++ #ifndef PERSON_H #define PERSON_H #include
|
#include "Person.h" string Person::get_name() { return name; } string Person::get_best_friend() { if (best_friend != 0) // check for null pointer return best_friend->name; else return ""; } int Person::get_popularity() { return popularity; } void Person::set_best_friend(Person * bf) { best_friend = bf; (bf->popularity)++; } |
#include |
4. Modify the program to prevent duplicate names being inserted in the vector and modify the program to prompt the user for another name if best friend is not found.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
