Question: #include using namespace std; class BookRecord { public: string title = NULL; string author = NULL; int num _ pages = - 1 ; int
#include
using namespace std;
class BookRecord
public:
string title "NULL";
string author "NULL";
int numpages ;
int yearpublished ;
bool isequivBookRecord rhs
if title rhstitle && author rhsauthor && numpages rhsnumpages
&& yearpublished rhsyearpublished
return true;
else
return false;
void display
cout "Author Name: author endl;
cout "Title: title endl;
cout "Pages: numpages endl;
cout "Year Published: yearpublished endl;
cout endl;
;
class Node
public:
BookRecord data;
Node next nullptr;
Node prev nullptr; New prev pointer for doubly linked list
;
class DoublyLinkedList
private:
Node head nullptr;
Node tail nullptr; Pointer to the last node for convenience
public:
void display;
void displayreverse;
void insertHeadBookRecord val;
void insertEndBookRecord val;
void insertAtBookRecord val, int pos;
void deleteHead;
void deleteEnd;
void deleteAtint pos;
int size;
DoublyLinkedList;
DoublyLinkedListBookRecord vals int numvals;
DoublyLinkedListconst DoublyLinkedList& orig;
~DoublyLinkedList;
;
Definitions
void DoublyLinkedList::insertHeadBookRecord val
Node newnode new Node;
newNode data val;
ifhead
head new Node;
headdataval;
void DoublyLinkedList::display
Node temp head;
while
void DoublyLinkedList::displayreverse
void DoublyLinkedList::insertEndBookRecord val
void DoublyLinkedList::insertAtBookRecord val, int pos
void DoublyLinkedList::deleteHead
void DoublyLinkedList::deleteEnd
void DoublyLinkedList::deleteAtint pos
int DoublyLinkedList::size
return ;
DoublyLinkedList::DoublyLinkedList
cout "Calling default constructor." endl;
DoublyLinkedList::DoublyLinkedListBookRecord vals int numvals
cout "Calling parameterized constructor!" endl;
DoublyLinkedList::DoublyLinkedListconst DoublyLinkedList& orig
cout "Executing copy constructor for DoublyLinkedList!" endl;
DoublyLinkedList::~DoublyLinkedList
cout "Executing Destructor for DoublyLinkedList!" endl;
void fooDoublyLinkedList lst
lstdisplay;
cout endl;
int main
BookRecord book book book book;
booktitle "Digital Design and Computer Architecture";
booknumpages ;
bookyearpublished ;
bookauthor "David Harris";
booktitle "A Game of Thrones";
booknumpages ;
bookyearpublished ;
bookauthor "George R R Martin";
booktitle "Thrawn Star Wars;
booknumpages ;
bookyearpublished ;
bookauthor "Timothy Zahn";
booktitle "The C Programming Language";
booknumpages ;
bookyearpublished ;
bookauthor "Bjarne Stroustrup";
DoublyLinkedList list;
cout Testing insertHead endl;
listinsertHeadbook;
listinsertHeadbook;
listinsertHeadbook;
listinsertHeadbook;
listdisplay;
cout Testing displayreverse endl;
listdisplayreverse;
cout Testing insertEnd endl;
listinsertEndbook;
listinsertEndbook;
listinsertEndbook;
listdisplay;
cout Testing deleteHead endl;
listdeleteHead;
listdisplay;
cout Testing size endl;
listdisplay;
cout "There are listsize elements in the linked list." endl;
cout Testing parameterized constructor. endl;
BookRecord vals book book book book;
DoublyLinkedList listvals;
listdisplay;
cout Testing copy constructor. endl;
foolist;
cout Testing insertAt endl;
listinsertAtbook;
listdisplay;
cout Testing deleteEnd endl;
listdeleteEnd;
listdisplay;
cout Testing deleteAt endl;
listdeleteAt;
listdisplay;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
