How do I do this,
I have a class called LargeInteger that stores a number of maxmimum 20 digits. I made the constructor
LargeInteger::LargeInteger(string number){ init(number); }
Now if the number is > LargeInteger::MAX_DIGITS (static const member) i.e 20 i want to not create the object and throw an exception.
I created an class LargeIntegerException{ ... }; and did this
void init(string number) throw(LargeIntegerException);
void LargeInteger::init(string number) throw(LargeIntegerException)
{
if(number.length > MAX_DIGITS)
throw LargeIntegerException(LargeIntegerException::OUT_OF_BOUNDS);
else ......
}
So now i modified the constructor
LargeInteger::LargeInteger(string number)
{ try {init(number);} catch(LargeIntegerExceptione) {...} }
Now I have 2 questions
1.Will the object of this class be created incase an exception is thrown?
2.How to handle it if the above is true?