Answer to Question #278220 in C++ for Gopi

Question #278220

Write a program to implement exception handling in constructors and destructors. Also use multiple c

1
Expert's answer
2021-12-11T01:58:03-0500
#include <iostream>

class Fraction {
public:
  Fraction(double num, double dom) {
    try {
      if (dom == 0) throw dom;
      numerator = num;
      dominator = dom;
    } catch (double dom) {
      cout << "Zero division!" << endl;
    }
  }
  ~Function() {}
private:
  double numerator;
  double dominator;
}

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

LATEST TUTORIALS
New on Blog