Show: Object Pascal C++
Display Preferences

Handling Errors For The New Operator

From Appmethod Topics
Jump to: navigation, search

Go Up to The new And delete Operators Index

By default, new throws the bad_alloc exception when a request for memory allocation cannot be satisfied.

You can define a function to be called if the new operator fails. To tell the new operator about the new-handler function, use set_new_handler and supply a pointer to the new-handler. If you want new to return null on failure, you must use set_new_handler(0) .

See Also

Personal tools
In other languages