-
What is the output of this program?
#include <iostream>
using namespace std;
class TestClassA
{
};
class TestClassB : public TestClassA { };
void Function();
int main()
{
try
{
Function();
}
catch (const TestClassA&)
{
cout << "Caught an exception" << endl;
}
return 0;
}
void Function()
{
throw TestClassB();
}
-
- Caught an exception
- Compilation Error
- Runtime Error
- Garbage value
- None of these
Correct Option: A
In this program, We are arising with the exception by using the method in the class.