"Sean" <an*******@discussions.microsoft.com> wrote in message
news:7e****************************@phx.gbl...
I know that some variables are stored on heaps and some on
stack in C++. How about functions? where does function
reside on memory? Is it stack or heap?
Neither. When you run an application, Windows' loader inspects the image
file, pre-allocates memory and copies the binary executable (functions and
all) into the memory. This memory is not considered to be stack or heap. Why
do you want to know?
And are both function (not class member) and method
(function in a class) stored in the same location (either
stack or heap)?
As above.
I sense a bit of confusion, here. :-)
Stack and heap are used for dynamic allocations though most stack
allocations have much shorter lifetimes, functions tend to "live" for the
life of an application.
Regards,
Will