title: How should overriding delete in C++ behave?
body: <p>The problem I'm running into is that as far as I know the delete operator should be a static function but sometimes the compiler (VC++) seems to be treating it as dynamic.  </p>
  
  <p>Given:</p>
  
  <pre><code>class Base
  {
  public:
    void* operator new(size_t size) { /* allocate from custom heap */ }
    void operator delete(void *p) { customFree(p, sizeof(Base)); }
  
    Base() {}
    virtual ~Base() {}
  };
  
  class Derived: public Base
  {
  public:
    void* operator new(size_t size) { /* allocate from custom heap */ }
    void operator delete(void *p) { customFree(p, sizeof(Derived)); }
  
    Derived() {}
    virtual ~Derived() {}
  }
  </code></pre>
  
  <p>What I see happening is that deleting the base pointer will result in call to <code>Derived::opeator</code> delete.</p>
  
  <pre><code>Base *p = new Derived();
  delete p; //calls Derived::operator delete
  </code></pre>
  
  <p>If I don't define ANY <strong>destructors</strong> then I get what I expected to happen: Base::operator delete is called.  This seems to be happening because the compiler is inserting a function called 'scalar deleting <strong>destructor</strong> into the <strong>vtable</strong> when a <strong>destructor</strong> is defined.  Then that function will call <code>Derived::delete</code>.</p>
  
  <p>So I have to questions:
  1) Is this standard behavior?
  2) When should I be using</p>
  
  <pre><code>void operator delete( void *, size_t );
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>void operator delete( void * );
  </code></pre>
  
  <p>if the above is standard behavior?</p>