(Order of Exception Handlers) Write a program illustrating that the order of exception han- dlers is important. The first matching handler is the one that executes. Attempt to compile and run your program two different ways to show that two different handlers execute with two different ef- fects.

What will be an ideal response?


```
#include
#include
using namespace std;

// class TestException definition
class TestException : public runtime_error
{
public:
// constructor specifies error message
TestException::TestException( const string& message )
: runtime_error( message ) {}
}; // end class TestException
```
```
#include
#include "TestException.h"
using namespace std;

int main()
{
try // throw TestException
{
// throw an exception of the derived class
throw TestException( "This is a TestException" );
} // end try
catch ( runtime_error &exception ) // catch runtime_error exception
{
cout << "runtime_error was caught\n" << exception.what() << endl;
} // end catch
catch ( TestException &exception ) // catch TestException
{
cout << "TestException was caught\n" << exception.what() << endl;
} // end catch

return 0;
} // end main
```
runtime_error was caught
This is a TestException

Computer Science & Information Technology

You might also like to view...

You connect or link strings using the ____ operator, which is the ampersand (&).

A. join B. connect C. concatenation D. link

Computer Science & Information Technology

An indeterminate relationship between tables applies to the query only and is not defined for the entire database

Indicate whether the statement is true or false

Computer Science & Information Technology

After you have configured a certificate template for archival, certificates created from this template are archived in the CA's database. If a key is lost or corrupted, you can recover the key of a particular subject so that data protected by that key can be accessed. AD CS provides the _______________ for recovering private keys archived by the CA

a. CA administrator b. PKI administrator c. Key recovery agent d. None of the above.

Computer Science & Information Technology

Choose the correct adjective in the following sentence.Jane is the _____ of three siblings.?

A. ?older B. ?oldest

Computer Science & Information Technology