Network Class The Network class represents a network of people that are connected to each other and are able to contact and send messages to each other through the network. Create a Network class with the following: Member Variables A Network has just one private member variable: phonebook_ - a std::map which maps from a std::string for a person's name, to the std::shared_ptr object that belongs to that person. Constructor You do not need to explicitly define a constructor. The default constructor will implicitly be created for us by the compiler, initializing the phonebook_ to an empty map. AddPhone Create a function AddPhone that accepts a std::shared_ptr to a Phone and inserts that Phone to the phonebook_. The key is the name of that phone's owner, and the value is the shared pointer to the Phone. SendMessage Create a function SendMessage that accepts a std::shared_ptr to a Message and a const reference to a std::string representing the intended recipient of this message. You must check if the intended recipient is in the phonebook_, because if an invalid recipie
Network Class
The Network class represents a network of people that are connected to each other and are able to contact and send messages to each other through the network. Create a Network class with the following:
Member Variables
A Network has just one private member variable:
- phonebook_ - a std::map which maps from a std::string for a person's name, to the std::shared_ptr<Phone> object that belongs to that person.
Constructor
You do not need to explicitly define a constructor. The default constructor will implicitly be created for us by the compiler, initializing the phonebook_ to an empty map.
AddPhone
Create a function AddPhone that accepts a std::shared_ptr to a Phone and inserts that Phone to the phonebook_. The key is the name of that phone's owner, and the value is the shared pointer to the Phone.
SendMessage
Create a function SendMessage that accepts a std::shared_ptr to a Message and a const reference to a std::string representing the intended recipient of this message. You must check if the intended recipient is in the phonebook_, because if an invalid recipient is provided, no message should be sent over the network. If the recipient exists in the phonebook_, then use the Phone::AcceptMessage function to send that message to the recipient's phone.
SendMessage Overload
Create a function SendMessage that accepts a std::shared_ptr to a Message and a const reference to a



Step by step
Solved in 3 steps with 2 images









