Answer :
A function may return a pointer, but the programmer must ensure that the pointer still points to a valid object after the function ends.
Unless they are allocated on the heap, all objects within a function are kept on the stack. The Heap is not local storage for a particular function; rather, it is a global storage space that is always accessible.
Since the object inside the method is saved on the stack, accessing it after the function ends will be invalid. It's because after the function closes, the stack memory will be rolled back.
You must first create the object on the heap before returning the pointer in a secure manner. Only a small number of 8 bytes make up the pointer (on 64 bit machines).
To learn more about Pointer click here:
brainly.com/question/15561028
#SPJ4