getting an error within my code fro c++ and cannot figure outhow to resolve. what I am trying to do is Use exceptions so thatyour program handles the exceptions division by zero and invalidinput. codes are the following; fractiontype.h #pragma once
#ifndef FRACTIONTYPE_H
#define FRACTIONTYPE_H
#include
#include using namespace std; //the class for fractions which is dervied from the exceptionclass
class fractionException : public exception
{
private:
   const char *msg;
public:
   fractionException(const char *m) :msg(m) {}
   virtual const char *what() const throw()
   {
       return msg;
   }
}; //this is the class defintion for fraction
class fractionType
{
private:
   int n;
   int d;
public:
   fractionType() : n(0), d(1) {}
   fractionType(int num, int den) : n(num), d(den)
   {
       if (den == 0)
           throwfractionException(“Division by zero”);//this gives the zeroexception
   }    fractionType operator/(const fractionType&x);
   friend ostream & operator
   friend istream& operator>>(istream &in,fractionType &f);
};
#endif
//End Fraction Header MainProgram.cpp #include
#include
#include “fractionType.h”//this is the import
using namespace std; int main()
{
   try {        fractionType num1(1,0) ;        fractionType num2(0,3) ;        fractionTypenum3;        cout
   system(“pause”);
   return 0;
}
//main end FractionType.cpp #include “fractionType.h”
int main()
{
   std::ostream& operator
   {
       return os
   }    std::istream &operator>>(std::istream& is, fractionType & frac)
   {
       is >> frac.n;
       is >> frac.d;
       return is;
   }    fractionType operator/(fractionType const &a,fractionType const &b)
   {
       if (a.d == 0 || b.d == 0) throwfractionException(“Division by zero”);
       return fractionType{ (a.n * b.n) /(a.d * b.d) };
   } } Attached

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now