0
Working of the delete keyword
It says on here thst deleting a pointer pointing to some object of a class will destroy the object but that’ll only happen if the object is dynamically allocated right? Why would a normal object be destroyed if we delete a pointer pointing to it?!? Won’t just the pointer be deleted, and the object still stay there?
3 Answers
+ 12
To see the full article from MSDN (which Apoorva fetch the information from there) see:
[https://msdn.microsoft.com/en-us/library/h6227113.aspx]
+ 7
When delete is used to deallocate memory for a C++ class object, the object's destructor is called before the object's memory is deallocated (if the object has a destructor). If the operand to the delete operator is a modifiable l-value, its value is undefined after the object is deleted.
+ 2
The delete operator takes a pointer to a primitive or an object. Without a pointer, it wouldn't know what to delete. They can be overloaded, so it doesn't necessarily have to be real dynamic memory.
Hot today
Python — File Handling
1 Votes
Help me solve this (using loop)
3 Votes
What is wrong? Error on test.
1 Votes
Help me wiht python
1 Votes
Help me
0 Votes
Question is write a c program to print prime numbers up to n and print the largest number in array.
1 Votes
What’s wrong?
2 Votes