title: operator new already has a body
body: <p>I am trying to implement operator new with parameter as global. There is no problem if new without args is overloaded, but I get followings errors when trying to compile</p>
  
  <pre><code>inline void* operator new(size_t, void* p) {
      //...
      return p;
  }
  </code></pre>
  
  <blockquote>
    <p>c:\bjarne_exercise_6.cpp(14): error C2084: function 'void *operator new(size_t,void *) throw()' already has a body
              c:\program files\microsoft visual studio 10.0\vc\include\new(55) : see previous definition of 'new'</p>
    
    <p>c:\bjarne_exercise_6.cpp(40): error C2264: 'operator new' : error in function definition or declaration; function not called</p>
  </blockquote>
  
  <p>I have just solved this, you have to declare this before you #include stdafx.h
  No, not true. It compile well but still not this function is called but the version from new header file. It is so, because placement new(with 2 params) is already defined in new header. The ordinary new (with just 1, size_t parameter) is only declared there, so you can still overload it. So if you want special new with more than 1 parameter the solution suggested by @trion below is appropriate.</p>