Yspolzuyu compiler Dev-Cpp 5.4.1 TDM-GCC x64 4.7.1. This Tutorial Example of why not catch errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
static void operator delete(void *pointer)
{
char *data = (char*)pointer;
int i;
for(i = 0; i < 100; i++)data[i] = 0;
cout<<"secret safety"<<endl;
free(pointer);
}
int main(void)
{
char *pointer = new char[100];
strcpy(pointer, "Secret my company!"<<endl;
delete pointer;
}
|
Last edited on
Yes, it's an error to declare a replacement operator delete
as a static function.