Question: Please help in C++ Book.h #define BOOK_H #define BOOK_H #include using namespace std; class Book { public: Book(int=0, string=Unknown, string=Unknown, int=0); void setBook(int, string, string,

Please help in C++
Book.h
#define BOOK_H
#define BOOK_H
#include
using namespace std;
class Book
{
public:
Book(int=0, string="Unknown", string="Unknown", int=0);
void setBook(int, string, string, int);
void print();
private:
int id;
string title;
string author;
int year;
};
#endif
Book.cc
#include
#include
using namespace std;
#include "Book.h"
Book::Book(int i, string t, string a, int y)
{
id = i;
title = t;
author = a;
year = y;
}
void Book::setBook(int i, string t, string a, int y)
{
id = i;
title = t;
author = a;
year = y;
}
void Book::print()
{
cout
}
main.cc
#include
using namespace std;
#include
#include "Book.h"
#define MAX_ARR_SIZE 128
int mainMenu();
void printLibrary(Book arr[MAX_ARR_SIZE], int num);
int main()
{
Book library[MAX_ARR_SIZE];
int numBooks = 0;
string title, author;
int id, year;
int menuSelection;
while (1) {
menuSelection = mainMenu();
if (menuSelection == 0)
break;
else if (menuSelection == 1) {
cout
cin >> id;
cout
cin.ignore();
getline(cin, title);
cout
getline(cin, author);
cout
cin >> year;
library[numBooks].setBook(id, title, author, year);
++numBooks;
}
}
if (numBooks > 0)
printLibrary(library, numBooks);
return 0;
}
int mainMenu()
{
int numOptions = 1;
int selection = -1;
cout
cout
cout
while (selection numOptions) {
cout
cin >> selection;
}
return selection;
}
void printLibrary(Book arr[MAX_ARR_SIZE], int num)
{
cout
for (int i=0; i arr[i].print();
cout
}
Makefile
OPT = -Wall
t01: main.o Book.o
g++ $(OPT) -o t01 main.o Book.o
main.o: main.cc Book.h
g++ $(OPT) -c main.cc
Book.o: Book.cc Book.h
g++ $(OPT) -c Book.cc
clean:
rm -f *.o t01
in.txt
1
101
Ender's Game
Card, Orson Scott
1985
1
102
Dune
Herbert, Frank
1965
1
110
Foundation
Asimov, Isaac
1951
1
111
Hitch Hiker's Guide to the Galaxy
Adams, Douglas
1979
1
112
1984
Orwell, George
1949
1
113
Stranger in a Strange Land
Heinlein, Robert A.
1961
1
114
Farenheit 451
Bradbury, Ray
1954
1
115
2001: A Space Odyssey
Clarke, Arthur C.
1968
1
116
I, Robot
Asimov, Isaac
1950
1
117
Starship Troopers
Heinlein, Robert A.
1959
1
118
Do Androids Dream of Electric Sheep?
Dick, Philip K.
1968
1
119
Neuromancer
Gibson, William
1984
1
120
Ringworld
Niven, Larry
1970
1
121
Rendezvous with Rama
Clarke, Arthur C.
1973
1
122
Hyperion
Simmons, Dan
1989
0
2. Create a new List collection class, along with the corresponding Node class, that holds a doubly linked list of Book pointers. You will implement the linked list as we saw in class, with no dummy nodes. The List class will contain: a data member for the head of the list, as a pointer to the first node in the list .a constructor .a destructor . an add (Book function that adds a new book to the list the new book will be added in its correct position, in ascending order by year, using to the Book class's lessThan) function a print () function that prints out the books to the screen the output will contain all the book data from the list traversed in the forward direction, followed by all the book data from the list traversed in the backward direction, to prove that the double links in the list are correct Make sure that all dynamically allocated memory is explicitly deallocated when the list is no longer used. Where's a good place for this cleanup code? 3. If you are starting from a previous tutorial, change the Library class to use a new List object instead of the existing Array object. There should be zero impact on existing classes because of this change except for minor changes to the Library class. There should be no changes to the control, View, and Book classes, nor to the main) function. 4. If you are starting from the base code, change the main) function so that it declares a new List object and uses it to store and print books 5. Build and run the program. Check that the books are ordered correctly, both in the forward direction and the backward direction, when the library is printed out at the end of the program. 6. Make sure that all dynamically allocated memory is explicitly deallocated when it is no longer used. Use valgrind to check for memory leakS 2. Create a new List collection class, along with the corresponding Node class, that holds a doubly linked list of Book pointers. You will implement the linked list as we saw in class, with no dummy nodes. The List class will contain: a data member for the head of the list, as a pointer to the first node in the list .a constructor .a destructor . an add (Book function that adds a new book to the list the new book will be added in its correct position, in ascending order by year, using to the Book class's lessThan) function a print () function that prints out the books to the screen the output will contain all the book data from the list traversed in the forward direction, followed by all the book data from the list traversed in the backward direction, to prove that the double links in the list are correct Make sure that all dynamically allocated memory is explicitly deallocated when the list is no longer used. Where's a good place for this cleanup code? 3. If you are starting from a previous tutorial, change the Library class to use a new List object instead of the existing Array object. There should be zero impact on existing classes because of this change except for minor changes to the Library class. There should be no changes to the control, View, and Book classes, nor to the main) function. 4. If you are starting from the base code, change the main) function so that it declares a new List object and uses it to store and print books 5. Build and run the program. Check that the books are ordered correctly, both in the forward direction and the backward direction, when the library is printed out at the end of the program. 6. Make sure that all dynamically allocated memory is explicitly deallocated when it is no longer used. Use valgrind to check for memory leakS