void* in malloc vs operator new
<p>Today I was writing a little Memory Profiler for my code and for the first time overloaded <code>operator new</code>. In doing so, I figured the syntax is <code>void* operator new(size_t sz)</code>. This is indeed very similar to <code>malloc</code> where you have <code>void* malloc(size_t sz)</code>.</p>

<p>This got me into thinking since when you use <code>malloc</code>, you need to explicitly cast the pointer  back to your data type whereas for new you don't need to do this. How does the compiler figure out the correct data type for <code>new</code> and why do you <em>have</em> to make it return <code>void *</code>? Isn't <code>T* operator new(size_t sz)</code> more intuitive?</p>
