For the first segment of code, should the memory of pt not be released yet within the void function?
This is not a good idea. The caller of funct(...) might not expect that the passed data will be deleted. A better approach would be to free the memory on the level where it is acquired.
The best approach would be using smart pointer.
The secon segment produces a memory leak. The memory acquired on line 10 is never freed.
Dangling pointers arise during object destruction, when an object that has an incoming reference is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory.
After line 10 in the first snippet, iptr is no longer valid. However, to the casual observer of main(), it's not immediately obvious that iptr has been released.