申論 2關於以下C++程式碼:01#include <iostream>02#include <string>03#include <exception>04#include <stdexcept>05#include <assert.h>06using namespace std;07class NegativeException: public exception {08const char * what () const throw () { return "negative"; }09};10class DivideByZeroException: public logic_error{11public:12DivideByZeroException() : logic_error( "divide by zero" ) {}13};14int getResult(int x, int y) {15if (x<0 || y<0) throw NegativeException();16else if (y==0) throw DivideByZeroException();17return (x/y);18}19void f(int x, int y) {20try { cout << "Result:"<< getResult(x, y)<<endl; }21catch (std::exception &e) { cout << "1: " << e.what() << "\n"; }22}23void testResult() {24f(2, -1);25f(2, 0);26f(2, 3);27f(6, 3);28}29void assertResult() {30assert(getResult(8, 4)==1);31}32int main() {33testResult();34assertResult();35return 0;36}㈠請說明程式執行後的輸出。(15分)㈡請說明程式中assert與exception的使用時機與目的。(10分)