We asked to add a reference to a student record, called bestFriend. The function displayStudentRecord(student *s) should display the first name, last name, and GPA of the student just as before. Additionally, if the “best friend” reference equal to the special value NULL, you should display “<name> has no friends (how sad!)”, or something similar. But if the best friend reference is not equal to the special value NULL, display the friend’s first name (only the first name, not the friend’s entire record. You might wonder why...)
After run my code below on ubuntu with g++, the error occur like below:
*** Error in `./a.out': double free or corruption (fasttop): 0x0000000000914140 ***
Aborted (core dumped)
http://www.cplusplus.com/forum/general/138037/
- if allocated with new[] deallocate with delete[]
- compare lines 62 and 65, you've got a copy-paste error
- new and new[] would throw an exception in case of failure, they would not return NULL
- leaks all over the place
That's cool. I just realized that.
Requirement:
• assign the second student as the best friend of the first student
• display the student records for both students (only one will have a a friend)
For the requirement, how can I make my input to be a value NULL? "If the best friend reference is not equal to the special value NULL, display the friend’s first name." cin doesn't work here.