Yes, it is on the heap.
Some information: When you use the βnewβ operator, it happens that the compiler allocates enough heap space for the class, including all the space needed for all member variables (which can also be classes, in which case their size must be calculated etc.).
After that, the constructor is called in the data element classes, then in the class itself.
Whenever you do not specifically allocate memory in a heap (usually using a new operator or calling a function that does this for you), memory is allocated on the stack, for example, the y variable in your example.
Edan maor
source share