how to print out all elements in a std::stack or std::queue conveniently

后端 未结 8 1731
忘掉有多难
忘掉有多难 2020-12-14 20:46

If I do not to want to create a new container in order to do so?

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 21:49

    1. If you need to do this, then stack or queue is not the correct choice of container.
    2. If you still insist on doing this, the best way is to make a copy and pop elements off of it and print them. I'm not going to suggest another way because there's no point.

提交回复
热议问题