Here in destructor why we are checking that if arr!=NULL then delete arr…
One doubt in distructor
Hey @ashishnnnnn
you can directly delete it as well because
Deleting a null pointer has no effect.
Its completely your choice
What if we don’t use distructor in our class???
Then also it will work but its a good practice to deallocate memory when its out of use.
Yaa… I wanted to make sure, that we are using distructor to delete the heap memory… as there will be no wastage of memory.
Thanks…
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.