This is not a C++ exception, it's an operating exception. Either you accessed memory that didn't exist or you corrupted a data structure and crashed its destructor. (I'm assuming you're trying to zero out a block before delete
ing the structure it contains.)
In C++ you don't typically call memset
. std::fill
does the same thing (and typically calls through to memset
if possible), but with type safety.
If you want to zero out blocks of memory before free
ing them, you need a debugging library. There's no clean way to access an object's memory after its destructor has been called and before free
is called. Debug malloc is probably a feature of your dev environment.
Edit: you might be able to access pre-free
memory for objects, but not arrays, by overriding delete
. But that is NOT an activity for a beginner/intermediate.