To raise an exception in C++, use the throw keyword. Objects in C++ can be thrown by value, or pointer:
// throw an object, to be caught by value or reference throw EIntegerRange(0, 10, userValue); // throw an object to be caught by pointer throw new EIntegerRange(0, 10, userValue);
throw 1; // throw an int throw "catastrophic error"; // throw a char *
In most cases, you want to throw exception objects because they can provide a more complete description of an error.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|