We have project that requires a special memory allocator so I am trying to overload the new and placement new operators. No matter what I try, I keep getting a syntax error from VS 2005 that says:
error C2084: function 'void *operator new(size_t,void *) throw()' already has a body.
Every article I Google and every C++ book I look at makes me think what I have should at least compile. My code is:
inline void* operator new (size_t size)throw(std::bad_alloc)
if (p==0) throw bad_alloc();
void* operator new (size_t size, void* p) throw()
if (p==0) throw std::bad_alloc();
It is only the new with two parameters that generates errors, which leads me to think that it is defined somewhere inside a system library. The only thing I found when googling was that if _CRTDBG_MAP_ALLOC is defined it will cause this error but I am not using that. If anyone can point out where I'm going wrong I'd appreciate it.