Need help on follwing program for c language Define an excep

Need help on follwing program for c++ language.

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. Please seprate all three files, header file, implementation file, and main file.

Solution

// using tornado exceprion
#include <iostream>
#include <exception>

using namespace std;

class tornadoException: public exception
{
tornadoException::tornadoException(){
   return \"Tornado: Take cover immediately!\";
}  
tornadoException::tornadoException(int m){
   return \"Tornado: \"+m+\" miles away; and approaching!\";
}  
};

-------------------------------------------------------------------------------------------------------------------------------------------------------

// main file

#include <iostream>

using namespace std;

int main ()
{
tornadoException myexe;

try
{
throw myexe;
}
catch (exception& e)
{
cout << e << endl;
}
return 0;
}

Need help on follwing program for c++ language. Define an exception class called tornadoException. The class should have two constructors, including the default

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site