View Full Version : STL Stacks
11-10-2004, 10:35 PM
I have a question about the STL stack member:
bool operator < (const stack&, const stack&)
In the STL description it says "Lexicographical ordering of two stacks."
anyone think they could explain how exactly this determines which stack is greater/less than the other? I'm just lost on this one.
11-10-2004, 10:55 PM
Well this is usually in terms of a recursive function. (I've never actually used STL though) Each item in the stacks are compared to each other. If the first match, it moves to the second, if the second match onto the third and so on untill a result is happend on or the stack is depleted.
You do understand how the prototype works right?
11-10-2004, 11:18 PM
no not really, I grasp the whole stack concept and I know how to use them, I just don't really understand how it is compared, like if there were 2 integer stacks.
what would a<b return?
11-10-2004, 11:35 PM
Yeah it would.
The prototype is just overloading the < operator as a function name.
[edit:] lol, just reread your question... and the answer is the question, which is why I gave a weird answer.
a<b would return a<b .. The prototype says it returns a boolean so it would return true because a is < b.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.