public member function
<exception>
std::exception::exception default (1)exception() throw();copy (2)
exception (const exception& e) throw();default (1)
exception() noexcept;copy (2)
exception (const exception& e) noexcept;
Construct exception
Constructs an exception object.The effects of calling member
whatafter a copy construction depend on the particular library implementation.
Every exception within the C++ standard library (including this) has, at least, a copy constructor that preserves the string representation returned by member
whatwhen the dynamic types match.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// exception constructor
#include <iostream> // std::cout
#include <exception> // std::exception
struct ooops : std::exception {
const char* what() const noexcept {return "Ooops!\n";}
};
int main () {
ooops e;
std::exception* p = &e;
try {
throw e; // throwing copy-constructs: ooops(e)
} catch (std::exception& ex) {
std::cout << ex.what();
}
try {
throw *p; // throwing copy-constructs: std::exception(*p)
} catch (std::exception& ex) {
std::cout << ex.what();
}
return 0;
}
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