Where is the memory for a local C++ vector allocated?

c++, vector

Solution

The vector is allocated on the stack (28 bytes on my system). The vector contents are allocated on the heap.

Problem

I noticed that the memory for vector is allocated dynamically. So for a local vector, where does the memory is allocated? ``` f(){ vector<int> vi; } ```

Original source

Related problems