March 10, 1998

Exceptions and operator new

Standard C++ states that operator new should throw an exception of type std::bad_alloc when it fails. This is different from previous stages of C++ and it means two important things: 1. If your code does not contain a catch statement to handle an std::bad_alloc exception, your program will crash whenever

Exception specification

A function that may throw an exception can warn its users about that by specifying a list of exceptions it may throw, thus helping its users to catch such exceptions appropriately: int divide (int, int) throw(zerodivide); //may throw an //exception of //type zerodivide (but //no other). If your function is