Competenze acquisite:
- Implementazione di classi template in C++
- Implementazione di template di funzioni in C++
- Lavoro con tipi generici e puntatori a funzione
The eighth module of the C++ piscine. The exercise requires implementing function templates for swap, min, and max. Swap() swaps the values of two given arguments. Min() compares two values and returns the smaller one. If the two values are equal, it returns the second one. Max() compares two values and returns the greater one. If the two values are equal, it returns the second one. The exercise requires implementing a function template called iter that takes three parameters: the address of an array, the length of the array, and a function to be called on each element of the array. The exercise requires developing a class template called Array that represents an array of elements of type T. The Array class should support various operations and functions, including construction without parameters (creating an empty array), construction with a specified number of elements (initialized by default), copying the class, the assignment operator, accessing elements using index operator, the size() member function that returns the number of elements in the array, and handling exceptions for out-of-bounds array access.
Skills acquired:
- Implementation of class templates in C++
- Implementation of function templates in C++
- Working with generic types and function pointers