## 19.3 Exceptions - Example

>     double future_value(double initial_balance, double p, int n)
>     {
>        if (p < 0 || n < 0)
>        {
>           logic_error description("illegal future_value parameter");
>           throw description;
>        }
>        return initial_balance * pow(1 + p / 100, n);
>     }

Note: `logic_error` is a standard exception class, declared in `<stdexcept>`

prev |top |next