In c++, I know local primary types are allocated on stack, and new
a customized class is allocated on heap.
But, what if create a the primary variable via new
, is it allocated on heap, or still on stack?
e.g:
function void test() {
int *pi = new int(1);
}
I knew there is a pointer pi
on the function's stack.
But, what about the object it point to (aka *pi
), is it on stack or heap?
Wondering is it similar as the primary wrapper type (e.g Integer
) from Java.