Home / MCQ Bank / Computer
Computer Plus Plus Miscellaneous Difficulty: Medium

What will be the output of the following C++ code? #include <typeinfo> #include <iostream> 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<mytriangle&>(ref_Myshape); } catch (bad_cast) { cout << "Can't do the dynamic_cast lor!!!" << endl; cout << "Caught: bad_cast exception. Myshape is not mytriangle.\n"; } return 0; }

Select the correct option to test your answer:

More Computer Questions

Which type of binary search tree is imitated for construction of tango tree? What is the shortcut key to start presentation from current slide? What is the TLS protocol? Addressing structure Which of the following sorting algorithm is in-place?