ostream& operator<<(ostream& out, const LinkedQueue& queue)
{
ListNode *iter = new ListNode(queue.first());
while(iter != NULL) {
out << iter->getElem() << " ";
iter = iter->getNext();
}
return out;
}
This is my closest because it will at least print out the first element but that is it. I already did a linkedlist where I set an listnode to point to the head of the list, and then while cycling through it I would just getElem(), so I'm trying that here, however my problem this time is that LinkedQueue doesnt have a head, and I cant use the ll.getHead() because LinkedList ll is private.
So could someone point me in the right direction on how to do this?
I cant use the ll.getHead() because LinkedList ll is private.
To avoid this problem is exactly why you made operator << a friend function.
This cannot be done without access to head of ll. If you really can't do it, you made a mistake while giving access rights to members of LinkedList (getHead should be public).