h8n2
h8n2

Reputation: 679

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

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?

Upvotes: 0

Views: 121

Answers (0)

Related Questions