Practice mode C++

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.