บทนำ
มีความแตกต่างสำคัญใน Exception Handling ระหว่าง C++ และ Java
| Exception handling in Java | Exception handling in C++ |
|---|---|
| โยนได้เฉพาะ throwable objects | โยนได้ทุกชนิดข้อมูล (All types) |
| มี finally block รันหลัง try-catch สำหรับ cleanup | ไม่มี finally block |
| ใช้คีย์เวิร์ด throws ระบุ exception ที่ฟังก์ชันอาจโยน | ใช้คีย์เวิร์ด throw ระบุ exception ที่ฟังก์ชันอาจโยน |
| มีทั้ง checked และ unchecked exceptions | มีแค่ unchecked exceptions |