I need to add a CD with all of its songs to a collection. I'm trying to figure out how to remove a CD from a CD collection. For example, When I append the artist name, the name of the CD, and the title, and length of each song and call the display function it displays all of the information. When I call the deleteNode function with the artist, name of CD, and length of CD as parameters, the display function still displays what I appended. The program builds fine but I don't think I'm calling the deleteNode function correctly. Also, the linked list has the data type of the class.
The Struct
class CD { private: string artist; // To hold artist nam string name; // To hold name of CD struct disc { string title; // To hold title of the song double length; // To hold length of the song }my_disc; } Calling the deleteNode function from main
void remove_cd(LinkedList1<CD> *remove) { cout << "Enter the name of the artist of the CD you wish to remove: "; cin.ignore(); getline(cin, artist); cout << "Enter the title: "; cin >> title; cout << "Enter the length: "; cin >> length; CD removeNode(artist, title, length); remove->deleteNode(removeNode); } If I use the artist, name, and length) as parameters for deleteNode how do I get it to remove all of the songs that have been inserted too? I want to actually delete the CD
The deleteNode function in the linkedlist
template <class T> void LinkedList1<T>::deleteNode( T searchValue) { discList **pp = &head; while (*pp && (*pp)->value != searchValue) pp = &(*pp)->next; if (*pp) { discList *victim = *pp; *pp = victim->next; delete victim; } } Overloaded operators in CD
bool CD::operator == (const CD &e) { if (artist == e.artist) return true; return false; } bool CD::operator != (const CD &e) { if (artist != e.artist) return true; return false; }