stdexcept


1. Exception Handling in Array Indexing

int main() {
  // Create an array of size 5
  int arr[] = {1, 2, 3, 4, 5};

  try {
    // Attempt to access an index out of bounds
    int value = arr[5];
    std::cout << "Value at index 5: " << value << std::endl;
  } catch (std::out_of_range& e) {
    std::cout << "Exception: " << e.what() << std::endl;
  }

  return 0;
}

2. Exception Handling in File Operations

int main() {
  try {
    // Open a file that does not exist
    std::ifstream file("non_existing_file.txt");
  } catch (std::ifstream::failure& e) {
    std::cout << "Exception: " << e.what() << std::endl;
  }

  return 0;
}

3. Exception Handling in Pointer Dereferencing

4. Exception Handling in Function Calls

5. Exception Handling in Class Constructors

6. Exception Handling in Destructors

7. Exception Handling in operator overloading

8. Exception Handling in Copy Constructors

9. Exception Handling in Default Constructors

10. Exception Handling in Move Constructors

11. Exception Handling in Iterators

12. Exception Handling in Function Templates

13. Exception Handling in Class Templates

14. Exception Handling in operator Overloading Templates

15. Exception Handling in Test Fixtures

16. Exception Handling in Assertion Macros

17. Exception Handling in Catch Blocks

18. Exception Handling in Nested Catch Blocks