I've been reading up on the difference between the heap and the stack, which is where
my question spawns from.
I'm pretty sure I get it, but here's what I think I know.
heap is the rest of your computers memory which has not been allocated to the OS
or some app or another, including the running app.
If you create a variable with new keyword, it's created on the heap.
If you create a variable without the keyword it is created on the stack.
My question is, where is the pointer created, which is used to access a variable created
on the heap?
int * pNum = new int(); // pNum is a pointer to an int created on the heap (I think)
Where does the actuall pointer pNum reside?
EDIT:
I suppose it would have to be created on the stack else the user/caller would
not know where to find the new int on the heap.
I'm often wrong though.
my question spawns from.
I'm pretty sure I get it, but here's what I think I know.
heap is the rest of your computers memory which has not been allocated to the OS
or some app or another, including the running app.
If you create a variable with new keyword, it's created on the heap.
If you create a variable without the keyword it is created on the stack.
My question is, where is the pointer created, which is used to access a variable created
on the heap?
int * pNum = new int(); // pNum is a pointer to an int created on the heap (I think)
Where does the actuall pointer pNum reside?
EDIT:
I suppose it would have to be created on the stack else the user/caller would
not know where to find the new int on the heap.
I'm often wrong though.