Where does a std::vector store its elements?
- A On the stack
- B On the heap, while the vector object itself may be on the stack
- C In static storage
- D In registers
Answer
On the heap, while the vector object itself may be on the stack
This is why a vector can hold far more data than a stack-allocated array, and why its destructor must free the buffer.





