-
What is the output of this program?
#include <iostream>
#include <exception>
#include <typeinfo>
using namespace std;
class Sample
{
virtual int Function()
{
}
};
int main ()
{
try
{
Sample *ptr = NULL;
typeid (*ptr);
}
catch (std::exception& TypeVar)
{
cout << "Exception Occurred: " << TypeVar.what() << endl;
}
return 0;
}
-
- Compilation Error
- Null
- Exception Occurred: std::bad_alloc
- Exception Occurred: std::bad_typeid
- None of these
Correct Option: D
As we are using a bad type on pointers, So it is arising an error.