Trouble overloading ==operator for comparing 2 queues

Apr 10, 2017 at 2:09am
I built this previously to compare 2 linked lists and it worked great. Now I'm trying to use it with a queue that uses a linked list and it always returns true as in the lists are the same. Not sure if it has something to do with the fact that queues use LIFO structure, but any help to fix this problem would be awesome.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//overload ==
bool list::operator==(list &l)
{
	node *current1 = new node;
	node *current2 = new node;

	current1 = head;
	current2 = l.head;

	while (current1 != NULL)
	{

		if (current1->data != current2->data)
		{
			return false;
		}
		current1 = current1->next;
		current2 = current2->next;
	}


	return true;
}
Apr 10, 2017 at 2:23am
queues use LIFO structure

this would be one hell of an unfair queue
Apr 10, 2017 at 2:31am
It doesn't does it? Would it be FIFO?
Apr 10, 2017 at 2:33am
Apr 10, 2017 at 2:35am
Thank you! Professor is losing it, her instruction literally says "Remember queues have LIFO structure."
Topic archived. No new replies allowed.