Take the Linked List from Problem 2 and let's create a linked list of songs. To achieve this, create a Song class with the following attributes: 1. Song Title 2. Song Author 3. Song Genre 4. Song Time (i.e., how long is the song in seconds) Songs should be sorted by Title. Write overloaded methods for the relational operations that compares the titles of a song. Create an Ordered Doubly Linked List and store random songs in the Linked List.
Please provide C++ program code to the following question. Please list and provide all steps with code solution and results of code when executed. .
![Take the Linked List from Problem 2 and let's create a linked list of songs. To
achieve this, create a Song class with the following attributes:
1. Song Title
2. Song Author
3. Song Genre
4. Song Time (i.e., how long is the song in seconds)
Songs should be sorted by Title. Write overloaded methods for the relational
operations that compares the titles of a song. Create an Ordered Doubly Linked
List and store random songs in the Linked List.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1dbff557-c987-45fc-8dd6-6084416c9157%2F36348d85-d66c-46a4-bd4c-20d4ff8a07e9%2Fixcnx6_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 8 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
This code is not working. I'm getting errors.Can you check code again.
#include <cctype>
#include <cstring>
#include <iostream>
using namespace std;
class Song {
private:
char* title;
char* author;
char* genre;
float time;
public:
Song();
Song(char* t, char* a, char* g, float ti);
~Song();
void Set(char* t, char* a, char* g, float ti);
void Display();
bool operator<(Song& a);
bool operator<=(Song& a);
bool operator>(Song& a);
bool operator>=(Song& a);
bool operator==(Song& a);
bool operator!=(Song& a);
};
Song::Song() {
title = NULL;
author = NULL;
genre = NULL;
time = 0;
}
Song::Song(char* t, char* a, char* g, float ti) {
title = new char[strlen(t) + 1];
strcpy(title, t);
author = new char[strlen(a) + 1];
strcpy(author, a);
genre = new char[strlen(g) + 1];
strcpy(genre, g);
time = ti;
}
Song::~Song() {
delete[] title;
delete[] author;
delete[] genre;
}
void Song::Set(char* t, char* a, char* g, float ti) {
title = new char[strlen(t) + 1];
strcpy(title, t);
author = new char[strlen(a) + 1];
strcpy(author, a);
genre = new char[strlen(g) + 1];
strcpy(genre, g);
time = ti;
}
void Song::Display() {
cout << "Title: " << title << endl;
cout << "Author: " << author << endl;
cout << "Genre: " << genre << endl;
cout << "Time: " << time << endl;
}
bool Song::operator<(Song& a) {
if (strcmp(title, a.title) < 0)
return true;
return false;
}
bool Song::operator<=(Song& a) {
if (strcmp(title, a.title) <= 0)
return true;
return false;
}
bool Song::operator>(Song& a) {
if (strcmp(title, a.title) > 0)
return true;
return false;
}
bool Song::operator>=(Song& a) {
if (strcmp(title, a.title) >= 0)
return true;
return false;
}
bool Song::operator==(Song& a) {
if (strcmp(title, a.title) == 0)
return true;
return false;
}
bool Song::operator!=(Song& a) {
if (strcmp(title, a.title) != 0)
return true;
return false;
}
int main() {
Song song1("Despacito", "Luis Fonsi", "Pop", 4.42);
Song song2("Shape of You", "Ed Sheeran", "Pop", 3.53);
Song song3("I Don't Wanna Live Forever", "Zayn Malik", "Pop", 4.10);
if (song1 < song2)
cout << "song1 comes before song2" << endl;
else
cout << "song1 does not come before song2" << endl;
if (song2 <= song3)
cout << "song2 comes before or is equal to song3" << endl;
else
cout << "song2 does not come before or is equal to song3" << endl;
if (song1 > song2)
cout << "song1 comes after song2" << endl;
else
cout << "song1 does not come after song2" << endl;
if (song1 >= song2)
cout << "song1 comes after or is equal to song2" << endl;
else
cout << "song1 does not come after or is equal to song2" << endl;
if (song1 == song2)
cout << "song1 is equal to song2" << endl;
else
cout << "song1 is not equal to song2" << endl;
if (song1 != song2)
cout << "song1 is not equal to song2" << endl;
else
cout << "song1 is equal to song2" << endl;
return 0;
}
![The image displays a screenshot of an error list from a development environment. It shows compilation errors for a project file named "Source.cpp" associated with the course "USM CSC 102 Set Limit 14."
### Error Details:
- **Total Errors:** 12
- **Total Warnings:** 0
- **Messages Displayed:** 0 of 15
#### Errors:
1. **Error Code E0289 (3 instances)**
- **Description:** "no instance of constructor 'Song::Song' matches the argument list"
- **Project:** USM CSC 102 Set Limit 14
- **File:** Source.cpp
- **Lines:** 105, 106, 107
2. **Error Code C4996**
- **Description:** "'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details."
- **Project:** USM CSC 102 Set Limit 14
- **File:** Source.cpp
- **Line:** 37
### Explanation:
- **E0289 Error:** The error indicates that the constructor for the class `Song` is not found with the provided argument list in the code at lines 105 to 107. This may require checking the definition of the `Song` class to ensure all needed constructors are defined.
- **C4996 Warning:** The warning indicates the use of `strcpy`, which is considered unsafe due to potential buffer overflow vulnerabilities. The suggested solution is to use a safer alternative, `strcpy_s`, or suppress the warning by defining `_CRT_SECURE_NO_WARNINGS`.
This error list is typical when compiling C++ code and assists developers in identifying and resolving issues to ensure their program compiles and runs correctly.](https://content.bartleby.com/qna-images/question/1dbff557-c987-45fc-8dd6-6084416c9157/be1e8289-a463-4292-a1e6-c09f92b49fc9/39ka0j_thumbnail.jpeg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)