I'm having a problem implementing the complexdivbyzero exception handler. It is supposed to be triggered if the user inputs a complex number with both the real and imaginary part being zero. Any help would be appreciated.
class ComplexDivByZero{};
complexType complexType::operator/ (const complexType& otherComplex) const throw (ComplexDivByZero)
{
complexType temp;
if (temp.realPart == 0 && temp.imaginaryPart == 0)
{
throw ComplexDivByZero();
}
else
{
//calculation
}
}
In main:
try
{
cout << num1 << " / " << num2 << " = " << num1 / num2 << endl;
}
catch(ComplexDivByZero)
{
cout << "Caught an exception!" << endl;
}
Warning:
warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)