Skip to content
Sign in
Computer PPSC

How do you define the user-defined exceptions?

Tap an option to check the answer. You can also press A–D.

Explanation
In C++, a user-defined exception is created by defining a class that inherits from the standard exception class (such as std::exception) and overriding its what() member function to return a custom error message. The exception object can then be thrown and caught like a built-in exception. Related facts: The what() function returns a description of the exception. User-defined exceptions make error handling specific to an application's own error conditions. Exam tip: Custom exception equals a new class inheriting the exception class plus an overridden what().