Is this possible? I need to read the data from a stack (and a queue), but I need to maintain the stack (and queue) so they can be used later.

I have not found any useful information online. My only thought is loading the data into a parallel stack before I pop through the original stack while I write out the data.

You should be able to use iterators.

If you are using std::stack, then there isn't any concept of iterators for std::stack, which makes sense.

As for your question, you can copy the stack content if needed. But it looks like you shouldn't be using stack in the first place?

I am using std::stack. I ended up copying the stack content. It is for an assignment. I think the point is to make us aware that this is a problem.

Thanks for confirming I would need to copy!

I am using std::stack. I ended up copying the stack content. It is for an assignment. I think the point is to make us aware that this is a problem.

Thanks for confirming I would need to copy!

ok, cool beans then

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.