A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_exception_what.htm below:

C++ Exception Handling Overview

C++ Exception Library - what Description

It is used to get string identifying exception.

Declaration

Following is the declaration for std::what.

virtual const char* what() const throw();
C++11
virtual const char* what() const noexcept;
Parameters

none

Return Value

It returns a null terminated character sequence that may be used to identify the exception.

Exceptions

No-throw guarantee − no members throw exceptions.

Example

In 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