Question: what is the difference between stack and vector in c++?
Answer: So, a vector can work as a stack, but a stack cannot work as a vector, because you cannot insert or get an element at a random position. stack is a stack. It can only push and pop. A vector can do other things, like insert into the middle.