1.

What is the output of this program?
#include <typeinfo>
#include <iostream>
using namespace std;
class AngleShape
{
public:
virtual void myvirtualfunc() const {}
};
class Triangle: public AngleShape
{
public:
virtual void myvirtualfunc() const
{
};
};
int main()
{
AngleShape Angleshape_instance;
AngleShape &ref_Angleshape = Angleshape_instance;
try
{
Triangle &ref_Triangle = dynamic_cast <Triangle& > (ref_Angleshape);
}
catch (bad_cast)
{
cout << "Can't do the Dynamic_cast" << endl;
cout << "Caught: bad_cast exception. AngleShape is not Triangle. n";
}
return 0;
}

A. Can t able to create the dynamic instance for the triangle, So it is arising an exception
B. Compilation Error
C. Runtime Error
D. Can't do the Dynamic_cast
E. None of these
Answer» B. Compilation Error


Discussion

No Comment Found

Related MCQs