how to read the top element in stack?

hi all.
i want to ask something about stack.
my assignment require me to do the bracket checking.
for example if i find ( or { , i push it into a stack.
then if i find } or ), i pop the element that i pushed into the stack before.

how do i read the element in the top??
i've tried this way.
s.top() == '{'
but it cannot be compiled.
anybody know about this? thanks. :)
top() should work assuming you're using the STL stack.

What error are you getting? Can you clarfiy what kind of stack you're using (is it the STL stack?) What is it a stack of? A stack of chars?
a really dumb question, but do you have the above statement within the if-statement?...
Topic archived. No new replies allowed.