Complete main() by inserting a new book into each list using the respective LinkedListLibrary
and VectorLibrary
InsertSorted() methods and outputting the number of operations the computer must perform to insert the new book. Each InsertSorted() returns the number of operations the computer performs.
Ex: If the input is:
The Catcher in the Rye
9787543321724
J.D. Salinger
the output is:
Number of linked list operations: 1
Number of vector operations: 1
Where I have been stumped on what to do with this assignment is how do I get the value of the counter, which is supposed to be increasing as operations are completed. When I compile and run the program all I get are 0 for both linked list operations and vector operations.
Am I calling the function in the other file the wrong way?
These are the lines of code that I wrote that are supposed to insert a new book and return the number of operations that it took to do so:
linkedListLibrary.InsertSorted(currNode, linkedListOperations);
vectorLibrary.InsertSorted(tempBook, vectorOperations);
Here is the bottom half of the code that I have so far (The part that I am having trouble with is near the bottom.)
currNode = new BookNode(bookTitle, bookAuthor, bookISBN);
// the number of operations performed
linkedListLibrary.InsertSorted(currNode, linkedListOperations);
linkedListLibrary.lastNode = currNode;
// Insert into VectorList
tempBook = Book(bookTitle, bookAuthor, bookISBN);
// TODO: Call VectorLibrary'
vectorLibrary.InsertSorted(tempBook, vectorOperations);
cout << "Number of linked list operations: " << linkedListOperations << endl;
cout << "Number of vector operations: " << vectorOperations << endl;
}
William S.
I set the int values linkedListOperations, and vectorOperations in the first half of the program to equal 0. I think my problem is that I am not passing the object correctly.03/03/21