The exception::what() used to get string identifying exception. This function returns a null terminated character sequence that may be used to identify the exception. Below is the syntax for the same:
virtual const char* what() const throw();
Return: The function std::what() return a null terminated character sequence that is used to identify the exception.
Note: To make use of std::what(), one should set up the appropriate try and catch blocks.
Below are the programs to understand the implementation of std::what() in a better way:
GeeksforGeeks!! A Computer Science Portal For Geeks
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- isalpha() and isdigit() functions in C with cstring examples.
- Pointers in C/C++ with Examples
- strtok() and strtok_r() functions in C with examples
- memset() in C with examples
- std::mismatch() with examples in C++
- wcscpy() function in C++ with Examples
- wcscmp() function in C++ with Examples
- set_symmetric_difference in C++ with Examples
- ratio_equal() in C++ with examples
- std::equal_to in C++ with Examples
- quick_exit() function in C++ with Examples
- feclearexcept in C++ with Examples
- Understanding Lvalues, PRvalues and Xvalues in C/C++ with Examples
- multiset lower_bound() in C++ STL with Examples
- multiset upper_bound() in C++ STL with Examples
- multiset max_size() in C++ STL with Examples
- forward_list max_size() in C++ STL with Examples
- std::allocator() in C++ with Examples
- array data() in C++ STL with Examples
- multiset size() in C++ STL with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.