Q46
What will be the output of the following C++ code? #include #include using namespace std; class shape public: virtual void myvirtualfunc() const ; class mytriangle: public shape public: virtual void myvirtualfunc() const ; ; int main() shape shape_instance; shape &ref_shape = shape_instance; try mytriangle &ref_mytriangle = dynamic_cast(ref_shape); catch (bad_cast) cout << "Caught: bad_cast exception "; return 0;
A.
Caught standard exception
B.
No exception arises
C.
Caught: bad_cast exception
AnswerD.
Caught: cast
Answer: Option C
Solution
Answer: Option C
No explanation is given for this question Let's Discuss on Board