an old homework solution about linked lists written in c++