My solutions for the C++ module exercises at 42 School. Each exercise is to understand C++ concepts, mostly templating and STL (Standard Template Library), inheritance, polymorphism, and container adaptors.
- A C++ compiler supporting the C++98 standard
Each exercise directory contains a Makefile for easy compilation. To compile an exercise, navigate to its directory and run:
cd ex00 && make && ./ex00This will produce an executable named after the exercise (e.g., ex00, ex01, etc.), which you can then run:
Validated 27/02/2024. Grade: 100%.
- Directory:
ex00/ - Objective: Implement a template function
easyfindthat searches for a given integer in any STL container and throws an exception if the integer is not found. - Key Concepts: Templating, STL algorithms, Exception handling.
- Directory:
ex01/ - Objective: Develop a
Spanclass capable of storing a maximum number of integers and providing the shortest and longest span between stored integers. - Key Concepts: Class design, STL containers and algorithms, Dynamic memory management.
- Directory:
ex02/ - Objective: Extend the
std::stackcontainer to make it iterable, without altering its original functionality. By inheriting fromstd::stack, we introduce iterability to theMutantStackclass without changing its original stack functionality. This involves exposing iterators that allow traversal of the stack elements from bottom to top, effectively turning the stack into a linearly iterable container while retaining its LIFO (Last In, First Out) nature - Key Concepts: Inheritance, Container adaptors, Iterator protocol.
Each exercise includes a main function with comprehensive tests to demonstrate the functionality and to ensure correctness. After compiling an exercise, run the executable to see the test outcomes.