1.

What is the output of this program?
#include <iostream>
#include <typeinfo>
using namespace std;
class shapeClass
{
public:
virtual void Virtualfunc() const {}
};
class NewTriangle: public shapeClass
{
public:
virtual void Virtualfunc() const
{
};
};
int main()
{
shapeClass shape_object;
shapeClass &Ref_shape = shape_object;
try
{
NewTriangle &Ref_NewTriangle = dynamic_cast<NewTriangle&>(Ref_shape);
}
catch (bad_cast)
{
cout << "Exception caught by bad_cast";
}
return 0;
}

A. Compilation Error
B. Exception caught by bad_cast
C. Runtime Error
D. Garbage Value
E. None of these
Answer» C. Runtime Error


Discussion

No Comment Found

Related MCQs