Question
1.
#include
2.
#include
3.
using namespace std;
4.
struct MyException : public exception
5.
{
6.
const char * what () const throw ()
7.
{
8.
return "C++ Exception";
9.
}
10.
};
11.
int main()
12.
{
13.
try
14.
{
15.
throw MyException();
16.
}
17.
catch(MyException& e)
18.
{
19.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
struct MyException : public exception
5.
{
6.
const char * what () const throw ()
7.
{
8.
return "C++ Exception";
9.
}
10.
};
11.
int main()
12.
{
13.
try
14.
{
15.
throw MyException();
16.
}
17.
catch(MyException& e)
18.
{
19.
cout
Answer: Option C
Was this answer helpful ?
We are defining the user-defined exception in this program.
Output:
$ g++ excep4.cpp
$ a.out
C++ Exception
Exception caught
Was this answer helpful ?
More Questions on This Topic :
Question 5.
Which is used to throw a exception?
....
Question 6.
What is the use of the 'finally' keyword?
....
Submit Solution