What is the advantage of std::stack ?
I can't say any advantage only disadvantages :
-It doesn't allow to access the non-top elements : so debugging is impossible.
-It uses an other container inside.
So we might just go ahead and use std::vector (or deque or list), and strictly use only the back(), push_back() and pop_back() methods ( and operator[] for debugging)
So we might just go ahead and use std::vector (or deque or list), and strictly use only the back(), push_back() and pop_back() methods ( and operator[] for debugging)
The only advantage is that "std::stack" is more expressive than "std::vector" when the container you want to implement is truly a LIFO. It would help future maintainers. Of course you could partially offset that by naming the variable with the word "stack" in it, although that kinda implies you'll never want to change the container to anything other than a stack.
I presume you are talking about debugging via cout and not a debugger since any STL data structure is followable in the debugger with enough patience (I've traced enough maps in my lifetime, thank you).