Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / August 2004

Tip: Looking for answers? Try searching our database.

where does function reside in memory in C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sean - 17 Aug 2004 22:06 GMT
Hi all,

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?

And are both function (not class member) and method
(function in a class) stored in the same location (either
stack or heap)?

Thank you very much in advance.

regards,
Sean
William DePalo [MVP VC++] - 17 Aug 2004 23:09 GMT
> 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
Sean - 18 Aug 2004 01:24 GMT
Hi Will,

Thanks for your reply.
I'm just curious since we ocassionally have function
pointers and I was wondering where
the pointers point to? :)

regards,
Sean

>-----Original Message-----
>> I know that some variables are stored on heaps and some on
[quoted text clipped - 22 lines]
>
>.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.