Top "Delete-operator" questions

In the C++ programming language, the delete operator calls the destructor of the given argument, and returns memory allocated by new back to the heap.

Why would one replace default new and delete operators?

Why should would one replace the default operator new and delete with a custom new and delete operators? This is …

c++ operator-overloading new-operator c++-faq delete-operator
What is the right way to free a std::vector of pointers in C++?

I searched StackOverflow but couldn't find the answer to this question. Suppose I have a std::vector<Day *> …

c++ memory vector containers delete-operator
Heap corruption on delete[]

I've been getting heap corruption error on delete[] instruction. Project is worked on in VC++ 2008, its requirement (so please don't …

c++ runtime-error delete-operator heap-corruption
Delete objects of incomplete type

This one made me think: class X; void foo(X* p) { delete p; } How can we possibly delete p if …

c++ pointers forward-declaration delete-operator incomplete-type
How to delete void pointer?

Is there anything wrong when deleting an object like this in C++? MyCls* c = new MyCls(); void* p = (void*)c; …

c++ pointers void delete-operator
C++ delete - It deletes my objects but I can still access the data?

I have written a simple, working tetris game with each block as an instance of a class singleblock. class SingleBlock { …

c++ pointers undefined-behavior delete-operator c++-faq
C++ and when to use delete

I am re-reading some code from a while ago on C++ (I am learning Java in school right now), and …

c++ new-operator delete-operator
How to free memory in try-catch blocks?

I have a simple question hopefully - how does one free memory which was allocated in the try block when …

c++ try-catch delete-operator
Does delete[] call destructors?

I am writing a template class which internally manages an array of the given type. Like this: template<typename …

c++ delete-operator
How should I write ISO C++ Standard conformant custom new and delete operators?

How should I write ISO C++ standard conformant custom new and delete operators? This is in continuation of Overloading new …

c++ operator-overloading new-operator c++-faq delete-operator