Line 12: Problem here is you now have two lists pointing to the the same BookListNode.
You're going to have a problem, when you try to delete a node from your BookList. Deleting an entry from a BookList should delete the associated BookListNode. Once you do that, the other BookList is going to point to a BookListNode that no longer exists.
You should either use smart pointers, or create a copy of the BookListNode.
But now it says that for otherList, "no suitable conversion function from 'const BookList' to 'BookList::BookListNode* exists", which I understand how it's incorrect, but I'm not sure how else to work otherList into the code.
The BookListNode struct is declared as a private member of the BookList class. I'm supposed to code this without giving BookListNode its own constructor.
class BookList
{
private:
struct BookListNode
{
Book bookData;
BookListNode *next;
};
int length;
//Create a sample first item of the list
BookListNode *first;
public: .....
It will have an append method, but I haven't coded it yet, and I already deleted the return statement. Could you explain what those double asterisks do exactly?
Got it, thanks for all the help! One more thing, this is what I have for my Add method (which is separate from the "append to tail" method). This is supposed to add a new Book to the list (Book being another class I imported). This isn't correct, but am I in the ballpark?
1 2 3 4 5 6 7 8 9 10 11
void BookList::Add(const Book e)
{
struct BookListNode newNode;
for (int i = 0; i < length; i++)
{
newNote.bookData->next = e;
}
length++; //I set the length declaration to be equal to 0.
};