Exception Handling
Exception Handling
try {
2. catch in C++
The catch statement represents a block of code that is executed when a
particular exception is thrown from the try block. The code to handle the
exception is written inside the catch block.
General Syntax:
catch (exception) {
// code to handle exception
}
3. throw in C++
An exception in C++ can be thrown using the throw keyword. When a
program encounters a throw statement, then it immediately terminates the
current function and starts finding a matching catch block to handle the
thrown exception.
General Syntax:
try {