Which catch block can be used to catch an exception of any type in C++?

Options

  • A. catch(int x)
  • B. catch(char x)
  • C. catch(...)
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. catch(...)

Detailed Explanation

Answer: (C) catch(...)

The ellipsis form catch(...) is known as the general or catch-all handler.

It can catch an exception of any type.

Specific handlers such as catch(int x) handle particular exception types, whereas catch(...) can be used when the exact exception type is not known or when a general handler is required.