throw
Go Up to Keywords, Alphabetical Listing Index
Category
Statements, C++ Specific Keywords
Syntax
throw assignment-expression
Description
When an exception occurs, the throw expression initializes a temporary object of the type T (to match the type of argument arg) used in throw(T arg). Other copies can be generated as required by the compiler. Consequently, it can be useful to define a copy constructor for the exception object.
Example
This example illustrates the use of the keyword throw.
void __fastcall TForm1::Button1Click(TObject *Sender) { throw(Exception("Hardware error: Divide by 0")); }