-
What is the output of this program?
#include <iostream>
#include <typeinfo>
using namespace std;
class Poly
{
virtual void Member(){}
};
int main ()
{
try
{
Poly * ptr = 0;
typeid(*ptr);
}
catch (exception& ex)
{
cout << "An Exception caught: " << ex.what() << endl;
}
return 0;
}
-
- An Exception caught: std::bad_alloc
- An Exception caught: std::bad_cast
- An Exception caught: std::bad_typeid
- All of above
- None of these
Correct Option: C
In this program, We used a bad type id for the polymorphic operator, So it is arising an bad_typeid exception.