does new throw or return NULL?

  • Thread starter Thread starter Servé Lau
  • Start date Start date
S

Servé Lau

I'm still seeing lots of code like this (taken from the MS directX samples:

apDSBuffer = new LPDIRECTSOUNDBUFFER[dwNumBuffers];

if( apDSBuffer == NULL ) {

hr = E_OUTOFMEMORY;

goto LFail;

}

I thought new throws an exception nowadays?
Am I correct?
 
I thought new throws an exception nowadays?
Am I correct?

It depends!

Have a look at Knowledge Base article 156808 "INFO: STL Sample for the
new operator Function" or the topic titled "new operator" in the
"Standard C++ Library Samples" section of MSDN, and the topic titled
"The new and delete Operators" in the "C++ Language Reference" section
of MSDN.

Dave
 
Back
Top