I had a quiz on the memory allocation topic, and this question came across that got me confused as I am not satisfied with the answers. (the Question)
As I have learned, we can create an "Object" on Heap by creating a pointer variable to point to the memory that we have allocated on Heap (using new
keyword).
For a specific example:
double* a = new double(-1.0f);
The Variable a
is a pointer and is created on the Stack point to a memory on the Heap. So actually, saying a
is allocated on the heap is wrong. Is my understanding is correct?