Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define an exception class called tornadoException. The class should have two constructors, including the default constructor. If the exception is thrown with the default constructor,

Define an exception class called tornadoException. The class should have two constructors, including the default constructor. If the exception is thrown with the default constructor, the method what should return "Tornado: Take cover immediately!". The other constructor has a single parameter, say, m, of the int type. If the exception is thrown with this constructor, the method what should return "Tornado: m miles away; and approaching!". Write a program to test this class. my biggest problem is getting it to display the distance. (all in c++): heres my code so far:

#include #include #include using namespace std;

class tornadoException { public: tornadoException() { message = " Tornado: take cover immediately"; } tornadoException(int m) {//this is where im having trouble tried "m" +m+ needs to display miles message = "tornado is:+m+ miles away "; }

string what() { return message; } private: string message; };

int main() { int miles; try{ cout<< "Enter miles"; cin >> miles; cout << endl;

if(miles <= 0){ throw tornadoException(); } else{ throw tornadoException(miles); } }

catch(tornadoException ex) { cout << " In TornadoException "<< endl << ex.what()<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago