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