V
Virchanza
I have a class.
When the user creates an object of this class, it supplies three
arguments to the constructor.
The user manual for the class says what values are valid for these
three arguments.
In the event that any of the three arguments have invalid values (as
specified by the user manual), I want to throw a very simple exception
that just supplies a text explanation.
Here's what I was *hoping* I could do:
MyClass::MyClass(int a, int b, int c)
{
if (a != 6)
{
throw std::exception("a must be equal to 6!");
}
}
Of course I can't do this because std::exception doesn't have a
constructor that takes a char const*.
So here's what I've go so far:
When the user creates an object of this class, it supplies three
arguments to the constructor.
The user manual for the class says what values are valid for these
three arguments.
In the event that any of the three arguments have invalid values (as
specified by the user manual), I want to throw a very simple exception
that just supplies a text explanation.
Here's what I was *hoping* I could do:
MyClass::MyClass(int a, int b, int c)
{
if (a != 6)
{
throw std::exception("a must be equal to 6!");
}
}
Of course I can't do this because std::exception doesn't have a
constructor that takes a char const*.
So here's what I've go so far: