Question
Help with Linked list for data structures with c++: Write a C++ program to implement a singly linked list of books. The book details should
Help with Linked list for data structures with c++:
Write a C++ program to implement a singly linked list of books. The book details should include the following: title, author, and ISBN. The program should include the following functions:
*addBook: This is a function to add a new book to the list.
*isInList: This is a function to check if a book exists in the list.
*compareLists: This is a function to check whether two lists have the same books.
The user should be allowed to chose and enter this information. I need help completing this program.
My current code:
#include
using namespace std;
struct node
{
int data;
node *next;
};
class linked_list
{
private:
node * head, *tail;
public;
linked_list()
{
head = NULL;
tail = NULL;
}
void addBook(int b)
{
node *tmp = new node;
tmp->data = b;
tmp->next = NULL;
if (head == NULL)
{
head = tmp;
tail = tmp;
}
else
{
tail->next = tmp;
tail = tail->next;
}
}
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started