0
What is main difference in new and delete?
Cpp
4 odpowiedzi
+ 6
new creat a object in heap memory or delete destroy objects in c++ but in java deletion works automatically.
+ 1
The new keyword is used to allocate memory in the heap for the object you create. Whereas delete keyword is used to delete that object you created so that the memory occupied by the object can be freed. Now that memory will be available and can be used once again by the user for some other task.
+ 1
And the most important is missed, which is if you forget to free memory from heap that's called Memory Leak which is a serious problem in your code.
0
Thanks