-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
35 lines (30 loc) · 878 Bytes
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <stdexcept>
class another_runtime_error: public std::runtime_error
{
public:
/**
* The following two constructors are extentions to the std::runtime_error constructors
*/
another_runtime_error(char *what_arg, int &which_arg): runtime_error(what_arg)
{
which_error = which_arg;
}
another_runtime_error(std::string &what_arg, int &which_arg): runtime_error(what_arg)
{
which_error = which_arg;
}
/**
* Function to get the error number stored in the thrown exception
*/
int which() { return which_error; }
private:
using std::runtime_error::runtime_error;
int which_error;
};
int main(int argc, char const *argv[])
{
another_runtime_error("Hello", 3);
int a;
return 0;
}