eg. int *a=new int(30);
now, delete a;
so it will delete the variable ‘a’ which is a pointer in stack and pointing in heap memory or it will delete the memory used by it
i am confused in it please tell me
Working of delete operator
@n.nishchaya2000 it will delete the memory used by it only, You can still assign other stuff to that variable. “delete” simply stops pointing a
at that heap memory
ma’am u are saying it will stop pointing a at that heap memory means previous stuff still there but no one is there now to access it
@n.nishchaya2000 yes it deallocates memory. The garbage value sits in the heap memory until a new variable gets assigned there and re-assigns that memory block