C++: how to handle exceptions?

Example:

int x = 10;
int y = 0;
int z = x / y;
C++ uses try-catch blocks for exception handling.

Solution:

try {
   if(y == 0) throw "Division by zero!";
   z = x / y;
} catch (const char* e) {
   std::cerr << "Exception: " << e << std::endl;
}

Beginner's Guide to C++