Quote:
Originally Posted by arun.viswanath
In the above program memory for the *ptr is created using new operator and the same memory is deleted using the delete. But after deleting the ptr also I can able to access the memory location using the ptr. So any one please explain me what new() and delete() actually does.
There's an error in that program, which someone else has already pointed out.
The reason you're able to use that memory after deleting it, is because it still exists. To oversimplify a bit, the new operator doesn't
create new memory, the memory already exists; the new operator is there to arbitrate who gets what piece of memory. So when you free the memory, it still exists, but now the new operator "knows" it's allowed to give it to someone else.