Answer to Question #287545 in C++ for amna

Question #287545

Create a class which only works for absolute numbers, if it

encounters any negative occurrence, then it throw an exception to its

handler and display errors.


Modify the above task, by creating an exception class with an error

code and corresponding error message. Code and message should be

thrown and displayed in catch block.


1
Expert's answer
2022-01-14T04:36:14-0500
#include <iostream>
using namespace std;
double negative(int x) {

	if (x <= 0) {
		throw "negative number!";
	}
	return (x);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment