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 2 1661
"Sean" <an*******@disc ussions.microso ft.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
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----- "Sean" <an*******@disc ussions.microso ft.com> wrote in
messagenews: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 imagefile, pre-allocates memory and copies the binary
executable (functions andall) into the memory. This memory is not considered to be
stack or heap. Whydo 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 stackallocations have much shorter lifetimes, functions tend
to "live" for thelife of an application.
Regards, Will
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jonas Rundberg |
last post by:
Hi
I just started with c++ and I'm a little bit confused where stuff
go...
Assume we have a class:
class test {
private:
int arr;
};
|
by: Ben |
last post by:
Hi, there.
Recently I was working on a problem where we want to save generic
closures in a data structure (a vector). The closure should work for
any data type and any method with pre-defined signature.
When developing this lib, I figured that the
pointer-to-member-function, although seemingly an attractive solution,
does not work well for us.
|
by: Marcus |
last post by:
Hello all,
This is baffling me. I am starting a session and I know it is setting a
cookie on my computer - I called getallheaders() and see that it is
setting the cookie, and it is also accessible in $_COOKIE. I cleared
all cookies in my Cookies folder before starting the session, and
everytime I run the script it does not create a cookie in the folder.
For testing I even set the browser to accept all cookies to make sure.
...
|
by: tkk |
last post by:
Hi All,
Is it possible to load a function at a particular address/memory
through the source program specification itself (or) is it upto
linker/loader combination which decides this?
For ex:
int hi()
{
return 0;
}
|
by: lasek |
last post by:
Hi...in some posts i've read...something about using macro rather then
function...but difference ??.
Best regards....
| |
by: puzzlecracker |
last post by:
Dynamically allocated objects reside on a heap, local objects on a
stack. What about static objects?
Thanks
|
by: Kislay |
last post by:
Which of the following is correct regarding the storage of global
variables :
1. Global variables exist in a memory area that exists from before the
first reference
in a program until after the last reference .
2.Global variables exist in the initialized data segment .
|
by: Anane |
last post by:
In my application I have 3 classes.
1. class A
2. class B
3. class C
Application controller (having main function) has the object of class A, class A has object of class B and class B has objects of class C.
Application Flow:
1. Application reads some inputs.
|
by: sidd |
last post by:
In the following code:
int i = 5; ---it goes to .data segment
int j; ---it goes to bss segment
int main()
{
int c;
int i = 5; ---stack
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |