Does new return (void *) in C++?
<p>This is a simple question :</p>

<p>Does using new operator return a pointer of type (void *)?
Referring to <a href="http://stackoverflow.com/questions/240212/what-is-the-difference-between-new-delete-and-malloc-free">What is the difference between new/delete and malloc/free?</a> answer - it says <code>new returns a fully typed pointer while malloc void *</code></p>

<p>But according to <a href="http://www.cplusplus.com/reference/new/operator%20new/" rel="nofollow">http://www.cplusplus.com/reference/new/operator%20new/</a> </p>

<pre><code>throwing (1)    
void* operator new (std::size_t size) throw (std::bad_alloc);
nothrow (2) 
void* operator new (std::size_t size, const std::nothrow_t&amp; nothrow_value) throw();
placement (3)   
void* operator new (std::size_t size, void* ptr) throw();
</code></pre>

<p>which means it returns a pointer of type (void *), if it returns (void *) I have never seen a code like MyClass *ptr = (MyClass *)new MyClass;</p>

<p>I have got confused .</p>

<p><strong>EDIT</strong></p>

<p>As per <a href="http://www.cplusplus.com/reference/new/operator%20new/" rel="nofollow">http://www.cplusplus.com/reference/new/operator%20new/</a>  example </p>

<pre><code>std::cout &lt;&lt; "1: ";
  MyClass * p1 = new MyClass;
      // allocates memory by calling: operator new (sizeof(MyClass))
      // and then constructs an object at the newly allocated space

  std::cout &lt;&lt; "2: ";
  MyClass * p2 = new (std::nothrow) MyClass;
      // allocates memory by calling: operator new (sizeof(MyClass),std::nothrow)
      // and then constructs an object at the newly allocated space
</code></pre>

<p>So <code>MyClass * p1 = new MyClass</code> calls <code>operator new (sizeof(MyClass))</code> and since <code>throwing (1)<br>
void* operator new (std::size_t size) throw (std::bad_alloc);</code> it should return <code>(void *)</code> if I understand the syntax correctly.</p>

<p>Thanks</p>
