What is the ellipsis catch handler in C++? Provide an example as well

In C++, the ellipsis catch handler is really quite simple. All it does is catch any unhandled exceptions. So, the ellipsis catch handler acts as a backup or last resort when no other handlers are appropriate. Here’s an example of what the ellipsis catch handler would look like:

Example of ellipsis catch handler

try
{
  throw "Something";
}

// the ellipsis catch handler:
catch(...)
{
cout << "There's no appropriate handler for this scenario";
}

Why is it called an ellipsis catch handler

The reason should be fairly obvious - it's the "...", which is also referred to as an ellipsis, and commonly used to mean something like "et cetera".

Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

Subscribe to our newsletter for more free interview questions.

Leave a Reply

Your email address will not be published.