Q176
What will be the output of the following C++ code? #include #include using namespace std; class Myshape public: virtual void myvirtualfunc() const ; class mytriangle: public Myshape public: virtual void myvirtualfunc() const ; ; int main() Myshape Myshape_instance; Myshape &ref_Myshape = Myshape_instance; try mytriangle &ref_mytriangle = dynamic_cast (ref_Myshape); catch (bad_cast) cout << "Can't do the dynamic_cast lor!!!" << endl; cout << "Caught: bad_cast exception. Myshape is not mytriangle. "; return 0;
A.
Can't do the dynamic_cast lor!!!
B.
Caught: bad_cast exception. Myshape is not mytriangle.
C.
Can't able to create the dynamic instance for the triangle, So it is arising an exception
AnswerD.
Myshape is not mytriangle
Answer: Option C
Solution
Answer: Option C
No explanation is given for this question Let's Discuss on Board