Name

bad_alloc class — Exception class for failed memory allocation

Synopsis

class bad_alloc : public exception {
public:
  bad_alloc(  ) throw(  );
  bad_alloc(const bad_alloc&) throw(  );
  bad_alloc& operator=(const bad_alloc&) throw(  );
  virtual ~bad_alloc(  ) throw(  );
  virtual const char* what(  ) const throw(  );
};
image with no caption

The bad_alloc class is an exception class that is thrown when operator new is unable to fulfill a request to allocate memory. As with any of the standard exception classes, what( ) returns an implementation-defined character string.

See Also

operator new , set_new_handler exception in <exception>

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.