Re: pop function in queue STL

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Jason Fox on December 03, 2001 at 00:07:32:

In Reply to: pop function in queue STL posted by Jay on December 02, 2001 at 23:46:19:

The problem is the STL queue template uses pop() to remove the item from the queue, but not return it. Before you pop an element from the queue, use front() to return the next value. Its a throwback to 'functional programming' where a single function should do a single "thing". Understandable, but rather annoyingly subtle in this example. Hope that helps!


: I have a queue using the STL and I have filled it with task objects. Now I am trying to acess those task objects by using pop. But it seems pop returns void. And when i do this:

: task popped
: popped = task_queue.pop()
: I get the error:F:\C++projects\tow\dispatcher.cpp(74) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)

: Can anyone help me out?

: Thanks

Follow Ups:

Post a Followup




Optional Link URL:
Link Title:
Optional Image URL:

[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]