1 | initial version |
A print statement does not free the value contained in a pointer. It just outputs the value of the pointer or the value pointed to by the pointer. The memory allocated to a pointer is freed using the delete
keyword or by going out of the scope where the pointer was declared, depending on how the memory was allocated. Improper use of delete
, such as trying to delete a pointer multiple times or trying to delete a pointer to a stack-allocated variable, can result in memory leaks or other undefined behavior.