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_constructor.htm below:

C++ Exception Constructor

C++ Exception Library - Constructor Description

It is constructor exception.

Declaration

Following is the declaration for std::exception::exception.

	
exception() throw();
exception (const exception& e) throw();
C++11
	
exception() noexcept;
exception (const exception& e) noexcept;
Parameters

e − It is an another exception object.

Return Value

none

Exceptions

No-throw guarantee − no members throw exceptions.

Example

In below example for std::exception::exception.

#include <iostream>       
#include <exception>      

struct ooops : std::exception {
   const char* what() const noexcept {return "Exception test!\n";}
};

int main () {
   ooops e;
   std::exception* p = &e;
   try {
      throw e;       
   } catch (std::exception& ex) {
      std::cout << ex.what();
   }
   try {
      throw *p;      
   } catch (std::exception& ex) {
      std::cout << ex.what();
   }
   return 0;
}

The sample output should be like this −

Exception test!
std::exception 

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