This module introduces C++ templates by implementing generic functions and a custom array class. It explores how to write type-agnostic, reusable code.
For each exercise, navigate to its folder, compile, and run:
๐ ex00
cd ex00
make
./whatever๐ ex01
cd ex01
make
./iter๐ ex02
cd ex02
make
./arrayex00 โ Start with a few functions: Implement function templates swap(), min(), and max() that work on any type supporting comparison and assignment. Test with both integers and strings.
ex01 โ Iter: Implement a template function iter() that applies a given function to each element of an array. It must handle both const and non-const arrays and support any type.
ex02 โ Array: Implement a class template Array with dynamic memory, safe element access, deep copy, bounds checking, and a size() method. Mimic basic behavior of std::vector without using STL.
If you have any questions or suggestions, feel free to connect: ๐ LinkedIn: Valentina Nguyen ๐โโ๏ธ
This project was developed and tested on Linux (Ubuntu).