devxlogo

Displaying Exceptions’ Description

Displaying Exceptions’ Description

Standard exception classes are derived from std::exception (defined in the header). They all implement the member function what(), which returns a const char * with a description of the exception:

  #include #include using namespace std;class A{};class B{   public: virtual ~B() {} };void main(){  B b;  try{    A a= dynamic_cast < A& > (b); //runtime exception; no conversion from B& to A& exists  }  catch (exception & ex) {    cout<< ex.what() <
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist