What will be the output of the following C++ code?#include using namespace std;class MyException{public:MyException(int value) : mValue(value){}int mValue;};class MyDerivedException : public MyException{public:MyDerivedException(int value, int anotherValue) : MyException(value), mAnotherValue(anotherValue){}int mValue;int mAnotherValue;};void doSomething(){throw MyDerivedException(10,20);}int main(){try{doSomething();}catch (MyDerivedException &exception){cout

🎲 Try a Random Question  |  Total Questions in Quiz: 296  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
C++ Programming Practice Test: Class Hierarchies, Library & Containers in C++ — practice the complete quiz, review flashcards, or try a random question.

C++ Quiz on on different aspects of a container which includes creation and design of new containers, vectors and sequences, types of inheritance and various class hierarchies, sequences like seq_con array class, seq_con vector class, stl – pair and heap, vtable, vptr, generators, array type manipulations, tuples, complex library, valarray, bitset and class relationships. Class Hierarchies: A class hierarchy in C++ is a structure where classes are organized in a tree-like manner, with a base class at the top and derived classes below it. The derived classes inherit the properties and methods... Show more

What will be the output of the following C++ code?<br>#include <iostream><br>using namespace std;<br>class MyException<br>{<br>public:<br>MyException(int value) : mValue(value)<br>{<br>}<br>int mValue;<br>};<br>class MyDerivedException : public MyException<br>{<br>public:<br>MyDerivedException(int value, int anotherValue) : MyException(value), mAnotherValue(anotherValue)<br>{<br>}<br>int mValue;<br>int mAnotherValue;<br>};<br>void doSomething()<br>{<br>throw MyDerivedException(10,20);<br>}<br>int main()<br>{<br>try<br>{<br>doSomething();<br>}<br>catch (MyDerivedException &exception)<br>{<br>cout << "\nCaught Derived Class Exception\n";<br>}<br>catch (MyException &exception)<br>{<br>cout << "\nCaught Base Class Exception\n";<br>}<br>return 0;<br>}