G
groleo
Hi list.
Simple question:
is it possible to override the global new/delete operators, without
using malloc/free?
I mean something in the ideea of the code below, which doesnt work
cause of
the recursivenes.
What I'm trying to say is how to override new/delete using the original
global
operators? ( if this is possible )
#include <stdio.h>
#include <malloc.h>
#include <new>
void*
operator new( size_t sz )
{
printf( "new\n" ) ;
return :perator new( sz );
//return malloc( sz );
}
void
operator delete( void* p )
{
printf( "delete\n" ) ;
:perator delete( p );
//free( p ) ;
}
int
main()
{
int* i = new(int) ;
delete i;
return 0;
}
Simple question:
is it possible to override the global new/delete operators, without
using malloc/free?
I mean something in the ideea of the code below, which doesnt work
cause of
the recursivenes.
What I'm trying to say is how to override new/delete using the original
global
operators? ( if this is possible )
#include <stdio.h>
#include <malloc.h>
#include <new>
void*
operator new( size_t sz )
{
printf( "new\n" ) ;
return :perator new( sz );
//return malloc( sz );
}
void
operator delete( void* p )
{
printf( "delete\n" ) ;
:perator delete( p );
//free( p ) ;
}
int
main()
{
int* i = new(int) ;
delete i;
return 0;
}