예외 처리 방법

    예외 처리 방법들

    예외 처리 방법들

    ▶일반적인 예외 처리 방법들 일반적인 예외 처리 방법들을 소개하기 위한 분모(bottom)가 0이 되면 안 되는 Rational 클래스를 만들겠습니다. #pragma once #include #include using namespace std; struct NegBotException { int top, bottom; NegBotException(int t = 1, int b = 0) : top(t), bottom(b) {} }; class Rational { int top;// 유리수의 분자 int bottom;// 유리수의 분모(0이 아니어야 함) public: double real() { return (double)top / bottom; //bottom이 0이면 안 됨 } }; 예외 상황에 대한 ..