I can answer the questions and get their output but I can't get beyond "Tracking Number" in the voidprintList(NoahsArk* Head) to display. I'm trying to get the Tracking Number, Animal and Boarding Charge to be displayed in column form.
It's a little more complicated than that. The OP is building a linked list. The OP needs to walk the list starting with HeadPointer and delete each item in the list.
@OP - I get compile errors in your program.
Line 37,42,60: OriginalPointer is undefined.
Line 53: Opening { is commented out.
Line 56: = missing.
Line 61: Head-> missing. You can't use endl on cin. Why are you doing a cin in a print function?
Should I get rid of the "Head" inside of the void PrintList?
Not sure if you're referring to the variable "Head" or the "print heading".
If you mean the variable "Head", then no. Passing in Head is perfectly reasonable. It removes the dependency on a global by moving the dependency to the caller.
If you mean the print heading, again, I would say no. PrintList is intended to print the entire list. I would however be inclined to move lines 56-58 to in front of the while loop.
I've edited those lines and I believe this may be the right coding now. I tested it with and without the delete pointer; and it didn't seem to make a difference, so should I still leave it?
To delete all the entries in the list, you have to "walk" the list (as you do in printList). e.g.
1 2 3 4 5 6 7 8
NoahsArk * curr = HeadPointer; // pointer to current node
NoahsArk * next; // We need to save the next pointer before we delete a node
while (curr)
{ next = HeadPointer->link;
delete [] curr;
curr = next;
}
I was never taught about curr so I'm not sure if we're allowed to use that in our code. Also, for the output, I couldn't my charging board output to show 2 decimal points. I typed in 30.50 and the output showed just 30
The animal type has to be a character array basically. Also I put the fixed setprecision line in but it still isn't showing up, I put it in main on line 33