Project 6 Explanation of Adding People and Friendships This is a quick walk-through of how memory changes as we add new people and friendships to Facebook. Consider a people.txt file that only contains the following: person harry gryffindor person ron gryffindor person hermione gryffindor friend harry ron friend harry hermione (This is a simplified version of the sample people.txt file.) The steps in the walk-through below are illustrated in the accompanying diagram. The parts of the diagram in red show what is new about each step. Step (1): Start of the program. We create a new facebook object (fb). The facebook object has a single private field, a vector of pointers to people called all_people, which begins empty. There is nothing on the stack. Step (2): We read from people.txt to add a person named Harry who is in Gryffindor. We allocate a person on the heap (with new) and set that person's name to Harry and house to Gryffindor. Harry starts out with no friends (everyone begins with no friends). We push_back a pointer to this dynamically-allocated person into all_people. (Note that because Harry was allocated on the heap, we *only have* a pointer to Harry. We don't have an actual variable that stores Harry's information, only a pointer that points to the information. So pushing_back a pointer to Harry is all we can do anyway.) Step (3): We read from people.txt to add a person named Ron who is also in Gryffindor. We allocate a person on the stack and set that person's name and house, then push_back a pointer to Ron into all_people. Step (4): We add Hermione to the database. Step (5): We read from people.txt to make Harry and Ron friends. In other words, we need to update Harry's list of friends to add Ron, and update Ron's list of friends to add Harry. We do this with a linear search over all_people to find the appropriate pointers to Harry and Ron. Once we find the pointer to Harry, we get Harry's friends and push_back a pointer to Ron. Then with the pointer to Ron, we get Ron's friends and push_back a pointer to Harry. Step (6): We repeat the same idea to make Harry friends with Hermione. Note that at the end of all of this, Harry has two friends (Ron and Hermione), but Ron and Hermione each have only one friend (Harry).