Which container does std::stack use as its underlying container by default?
Correct answer A. std::deque
Explanation
std::stack is a container adaptor, not a container in its own right. Its second template parameter defaults to std::deque, which offers efficient push_back and pop_back without reallocation of every element. You can choose std::vector or std::list instead, as in std::stack<int, std::vector>, because they also provide back, push_back and pop_back.
Answer checked How we write and check questions
Discussion