So after spending many years learning lots about computer science I've
decided to sit down and learn about computer programming.

So my first question is where in memory are objects that have been declared
"automatic".  Builtin types are obviously on the stack, as are C++ arrays.
However if you do something like this

vector<int> vec(24);

You get a vector with an initial size of 24 ints.  Where in memory is that,
is there some kind of pointer put onto the stack which then points into the
heap, or is the whole vector on the stack.  I could envision implementing it
either way.  Obviously if your using the new keyword the objects vtable is
going into the heap.  I'm specifically wondering about automatic allocation.

I like to know these things because depending on where in memory things go,
you may or may not want to take different defensive program measures to
prevent malicious or accidental data corruption problems.

Incidentally I do know how objects are structured in memory with regards to
vtables, just wondering where that vtable goes in C++ (g++)s automatic
allocation scheme.


Reply via email to