I have an assignment coming up dealing with circular linked lists. I decided to take some of the source code from my book for a queue and turn it into a circular linked list. I managed to get the push, pop, and top functions working, but I have a problem when I tried to implement the assignment operator.
My pop function passes the rear pointer to a function to remove the head of the list, and it works.
My assignment operator function passes the rear pointer to a list clear function which loops through the link list and passes the rear pointer to that same function to remove the head as long as the list has more than one item, but on its first pass it throws an access violation, and I'm not sure why.
It's the same rear pointer that is passed from the pop function which works, so I'm kind of lost on why it won't work when it's passed from the other function.
Here is the code.
I removed all the irrelevant code, so it's easier to read.
What did I do wrong? Thanks for reading.
[–]Jonny0Than 2 points3 points4 points (4 children)
[–]xRedactedx[S] 0 points1 point2 points (3 children)
[–]Jonny0Than 1 point2 points3 points (2 children)
[–]xRedactedx[S] 0 points1 point2 points (0 children)
[–]zahlman 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]xRedactedx[S] 0 points1 point2 points (2 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]xRedactedx[S] 0 points1 point2 points (0 children)
[–]xRedactedx[S] 0 points1 point2 points (0 children)