MCQs > IT & Programming > C++ > Consider the following code: class BaseException { public: virtual void Output() { cout << 'Base Exception' << endl; } }; class DerivedException : public BaseException { public: virtual void Output() { cout << 'Derived Exception' << endl; } }; void ExceptionTest() { try { throw new DerivedException(); } catch (DerivedException ex) { ex.Output(); } catch (...) { cout << 'Unknown Exception Thrown!' << endl; } } Invoking Exception Test will result in which output?

C++ MCQs

Consider the following code:

class BaseException
{
   public:
   virtual void Output()
   {
      cout << "Base Exception" << endl;
   }
};

class DerivedException : public BaseException
{
   public:
   virtual void Output()
   {
      cout << "Derived Exception" << endl;
   }
};

void ExceptionTest()
{
   try
   {
      throw new DerivedException();
   }
   catch (DerivedException ex)
   {
      ex.Output();
   }
   catch (...)
   {
      cout << "Unknown Exception Thrown!" << endl;
   }
}

Invoking Exception Test will result in which output?


Answer

Correct Answer: Base Exception

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it