operator new local to a class is required ?

T

Timothy Madden

Hello

I have just read (in a MSDN article named Deep C++, in part 8) that
member functions operator new and operator delete (and operator new[]
and operator delete[]) are required in order to have the language
automaticaly delete a memory bloc alocated with _new_ after the
constructor for the new object throws.

Is it true that only class delete is called in a new expresion to free
memory after the constructor throw ?

I am trying to write an exception-safe application. Idealy the app will
never crash, but will pop-up a message box and exit gracefully with full
clean-up if a fatal error like access violation occurs, be it anywhere
in the flow of control in my app. However I find this to be such a
difficult task to do !! It is ever more complicated.

Do you know of a good book that will fully explain to me how to
effectively use exception-handling in a real application ? The problem
gets even worse if you work with the odd code and design required by
Win32 and Win32 GUI...

Thank you
Timothy Madden
Romania
 
J

John Harrison

Timothy said:
Hello

I have just read (in a MSDN article named Deep C++, in part 8) that
member functions operator new and operator delete (and operator new[]
and operator delete[]) are required in order to have the language
automaticaly delete a memory bloc alocated with _new_ after the
constructor for the new object throws.

I've just read that article and I can't see what you read that made you
come to that conclusion.
Is it true that only class delete is called in a new expresion to free
memory after the constructor throw ?
No.


I am trying to write an exception-safe application. Idealy the app will
never crash, but will pop-up a message box and exit gracefully with full
clean-up if a fatal error like access violation occurs, be it anywhere
in the flow of control in my app. However I find this to be such a
difficult task to do !! It is ever more complicated.

There is no doubt, it is a difficult task. You do have to consider
whether the effort needed is worth it.
Do you know of a good book that will fully explain to me how to
effectively use exception-handling in a real application ? The problem
gets even worse if you work with the odd code and design required by
Win32 and Win32 GUI...

There is the Exceptional C++ series by Herb Sutter, personally I hate
the style but they do contain good information.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top