Hi,
I've got a header file which I use to fix Microsoft's new operator so that it will actually throw a bad_alloc exception like it is supposed to, but I can't get it to compile properly. Here is the interface:
When I compile, I get these errors:
"void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined"
"void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined"
If I remove the first (non-array) new and delete functions, it will compile without any problems. Why can't I overload them?
I've got a header file which I use to fix Microsoft's new operator so that it will actually throw a bad_alloc exception like it is supposed to, but I can't get it to compile properly. Here is the interface:
Code:
#ifndef OPERATOR_NEW_HEADER_FILE
#define OPERATOR_NEW_HEADER_FILE
#include <new>
#ifdef WIN32
#pragma warning(disable: 4290) // C++ Exception Specification ignored.
void* operator new( size_t size ) throw( std::bad_alloc );
void operator delete( void* pObject ) throw();
void* operator new[]( size_t size ) throw( std::bad_alloc );
void operator delete[]( void* pObject ) throw();
void* operator new( size_t size, const std::nothrow_t& ) throw();
void operator delete( void* pObject, const std::nothrow_t& ) throw();
void* operator new[]( size_t size, const std::nothrow_t& ) throw();
void operator delete[]( void* pObject, const std::nothrow_t& ) throw();
#endif // WIN32
#endif // OPERATOR_NEW_HEADER_FILE
"void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined"
"void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined"
If I remove the first (non-array) new and delete functions, it will compile without any problems. Why can't I overload them?