Hey Guys
Has anyone managed to write there own new and delete functions yet so you can do dynamic allocation in c++. If so i would love to have a look at your source as this is the next thing i need to do.
Peter
new and delete
Re:new and delete
Code: Select all
void *operator new(size_t size)
{
return malloc(size);
}
operator delete(void *ap)
{
free(ap);
}
Re:new and delete
Thanks for that
Is there a standard libary that this needs to go in, ie what is the name of the file i need to stick it in for my compiler to find it. Or do i just include it like any other function in a seperate file.
Peter
Is there a standard libary that this needs to go in, ie what is the name of the file i need to stick it in for my compiler to find it. Or do i just include it like any other function in a seperate file.
Peter
Re:new and delete
Put it anywhere you like. It's probably a good idea to put it in your C library, so that all applications can use new and delete.