Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

exception Class 

The class serves as the base class for all exceptions thrown by certain expressions and by the Standard C++ Library.


class exception {
public:
   exception( ); 
   exception(const char *const&);
   exception(const char *const&, int);
   exception(const exception&); 
   exception& operator=(const exception&); 
   virtual ~exception( );
   virtual const char *what( ) const;
};

Specifically, this base class is the root of the standard exception classes defined in <stdexcept>. The C string value returned by what is left unspecified by the default constructor, but may be defined by the constructors for certain derived classes as an implementation-defined C string. None of the member functions throw any exceptions.

The int parameter allows you to specify that no memory should be allocated. The value of the int is ignored.

For examples of the use of the standard exception classes that inherit from the exception class, see any of the classes defined in <stdexcept>.

Header: <exception>

Community Additions

ADD
Show:
© 2015 Microsoft