Answer to Question heap-5

No, newInt() is not an acceptable substitute for new int. Function newInt( ) returns a pointer into the run-time stack, since that is where variable n is stored. It points to the frame for newInt that is automatically deallocated when newInt returns. So it returns a dangling pointer.