CException is the base class for all exceptions in the Microsoft Foundation Class Library. The derived classes are listed below:
Class | Description |
CMemoryException | Out-of-memory exception |
CNotSupportedException | Request for an unsupported operation |
CArchiveException | Archive-specific exceptions |
CFileException | File-specific exceptions |
CResourceException | Windows resource not found or not creatable |
These exceptions are intended to be used with the THROW, THROW_LAST, TRY, CATCH, AND_CATCH, and END_CATCH macros. For more information on exception processing, see Chapter 5, “Exception Processing.” Also see the cookbook in the Class Libraries User's Guide.
#include <afx.h>
Use the derived classes to catch specific exceptions. Use CException if you need to catch all types of exceptions (and then use CObject::IsKindOf to differentiate among classes derived from CException.) All derived CException classes use the IMPLEMENT_DYNAMIC macro.
CException objects are deleted automatically. Do not delete them yourself.
Because CException is an abstract base class, you cannot create CException objects; you must create objects of derived classes. If you need to create your own CException type, use one of the derived classes listed above as a model.