It is used to get string identifying exception.
DeclarationFollowing is the declaration for std::what.
virtual const char* what() const throw();C++11
virtual const char* what() const noexcept;Parameters
none
Return ValueIt returns a null terminated character sequence that may be used to identify the exception.
ExceptionsNo-throw guarantee − no members throw exceptions.
ExampleIn below example for std::what.
#include <iostream> #include <exception> struct ooops : std::exception { const char* what() const noexcept {return "Ooops! It is a identity error\n";} }; int main () { try { throw ooops(); } catch (std::exception& ex) { std::cout << ex.what(); } return 0; }
The sample output should be like this −
Ooops! It is a identity error
exception.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4