🇫🇷 Version française disponible ici
This module introduces exceptions in C++ and focuses on handling errors safely and correctly.
Through these exercises, the goal is to learn how to throw, catch, and propagate exceptions, how to create custom exception classes, and how to ensure proper resource management even when errors occur. This reinforces robust object-oriented design.
Language
- C++ (C++98 standard)
Technologies
- Makefile
- Exception handling (
try,catch,throw) - Standard exceptions (
std::exception) - Custom exception classes
- Resource safety and memory management
- Strong exception safety guarantee
- Exception hierarchy and slicing
Introduction to basic exception handling:
- Handling standard exceptions
- Using
try,catch, andthrow
Creating and using custom exception classes:
- Implementing the
what()method - Throwing and catching custom exceptions
Ensuring resource safety and proper object management during exceptions:
- Proper constructor/destructor usage
- Avoiding memory leaks
Working with multiple exception levels and inheritance:
- Catching exceptions by base class type
- Understanding exception slicing
- Organizing error handling cleanly
All exercises are compiled using the following flags :
-Wall-Wextra-Werror-std=c++98
Note : this repository contains only the cpp_05 module. It is part of the global cpp_modules repository, which regroups all C++ modules.
- Clone
cpp_05in a folder first :git clone https://github.com/bibickette/cpp_05.git - Move into the repository :
cd cpp_05 - Compile the module :
make; this will compile all exercises contained in the module - You can now move into each exercices and run the corresponding executable
Project validation date : March 19, 2025