Can a stack machine be implemented with `std::stack`?

123 views Asked by At

I was reading up on stack machines today, and I started thinking whether it makes sense to implement it with std::stack in C++.

The issue with std::stack is that you can't access elements below the top of the stack without popping everything above the element of interest...

How would one implement it with std::stack?

I think you would have to use std::deque or std::vector or a custom data structure that allows you to access any element in the stack?

0

There are 0 answers