We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
classnegative_power:publicexception{constchar*what()constnoexcept//c-string return type{return"n and p should be non-negative";}}neg_pow;classCalculator{public:intpower(intnum,intpow){if(num<0||pow<0)throwneg_pow;elseif(pow==0)return1;elsereturnnum*power(num,pow-1);}};
Day 17: More Exceptions
You are viewing a single comment's thread. Return to all comments →
I made my own exception!