Category : C++ Source Code
Archive   : TEACHCPP.ZIP
Filename : EX03006.CPP

 
Output of file : EX03006.CPP contained in archive : TEACHCPP.ZIP
// ex03006.cpp
// Home-brew new and delete
#include
#include
#include

// ------------- overloaded new operator
static void *operator new(size_t size)
{
void *rtn = calloc(1, size);
return rtn;
}

// ----------- overloaded delete operator
static void operator delete(void *type)
{
free(type);
}

main()
{
// ------ allocate a zero-filled array
int *ip = new int[10];
// ------ display the array
for (int i = 0; i < 10; i++)
cout << " " << ip[i];
// ----- release the memory
delete ip;
}


  3 Responses to “Category : C++ Source Code
Archive   : TEACHCPP.ZIP
Filename : EX03006.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/