Create a linked list structure Music that contains the data fields Name, Artist,
ID: 3646037 • Letter: C
Question
Create a linked list structure Music that contains the data fields Name, Artist, Number_of_Songs, and a pointer to the list. Create the structure with 3 members and fill in data for each member. Create a function that will display() all the data for each member and call it from the main program.Explanation / Answer
// this code is related to liked list it will help u to create your own link list for more help related to programming check this link http://www.softwareandfinance.com/Visual_CPP/Singly_Linked_List.html #include #include struct Music { std::string Name; std::string Artist; std::int No_of_Songs; Music *forName; Music *Artist; Music *forSongs; SLinkList() : data(""), next(NULL) { } SLinkList(const char *value) : data(value), next(NULL) { } SLinkList* InsertNext(const char *data) { SLinkList *node = new SLinkList(data); if(this->next == NULL) { // Easy to handle node->next = NULL; // already set in constructor this->next = node; } else { // Insert in the middle SLinkList *temp = this->next; node->next = temp; this->next = node; } return node; } bool DeleteNext() { if(this->next == NULL) return false; SLinkList *pNode = this->next; this->next = this->next->next; // can be NULL here delete pNode; } void Traverse(SLinkList *node = NULL) { if(node == NULL) node = this; std::cout InsertNext("THREE"); SLinkList *node4 = node3->InsertNext("FOUR"); SLinkList *node5 = node4->InsertNext("FIVE"); node1->Traverse(); node3->DeleteNext(); // delete the node "FOUR" node2->Traverse(); std::coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.