My program freezes when it displays the contents of my linked list. I can not change the header, only the cpp file.
playlist.h:
class PlayList { private: struct SongNode { Song data; SongNode* next; SongNode (const Song& s, SongNode* nxt = 0) : data(s), next(nxt) {} }; friend std::ostream& operator<< (std::ostream& out, const PlayList& s); SongNode* first;
playlist.cpp
using namespace std; PlayList::PlayList() : totalTime(0,0,0) { } void PlayList::operator+= (const Song& song) { SongNode* newNode = new SongNode(song, first); first = newNode; }
When the list is displayed, all the data that should be printed is printed, but then the program freezes.
source share