Which is the correct syntax to delete a single object?In c++?
Answers
Answered by
0
delete() in C++
Delete is an operator that is used to destroy array and non-array(pointer) objects which are created by new expression.
Delete can be used by either using Delete operator or Delete [ ] operator
New operator is used for dynamic memory allocation which puts variables on heap memory.
Which means Delete operator deallocates memory from heap.
Pointer to object is not destroyed, value or memory block pointed by pointer is destroyed.
Here, Below are examples where we can apply delete operator:
1. Deleting Array Objects: We delete an array using [] brackets.
Hope this helps ☺️☺️
Similar questions
Social Sciences,
6 months ago
Physics,
6 months ago
Political Science,
1 year ago
Biology,
1 year ago