/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Array.tpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/23 14:28:55 by aortigos #+# #+# */ /* Updated: 2026/03/23 14:28:55 by aortigos ### ########.fr */ /* */ /* ************************************************************************** */ ////////////////// // Constructors // ////////////////// template Array::Array() : data(NULL), length(0) { // std::cout << "Array default constructor called" << std::endl; } template Array::Array(const Array &other) { data = new T[other.length](); length = other.length; for(unsigned int i = 0; i < length; i++) { data[i] = other.data[i]; } // std::cout << "Array copy constructor called" << std::endl; } template Array &Array::operator=(const Array &other) { if (this != &other) { // Copy attributes here delete[] data; data = new T[other.length](); length = other.length; for(unsigned int i = 0; i < length; i++) { data[i] = other.data[i]; } } // std::cout << "Array copy assignment operator called" << std::endl; return (*this); } template Array::~Array() { delete[] data; // std::cout << "Array destructor called" << std::endl; } template Array::Array(unsigned int n) : length(n) { data = new T[n](); } template T &Array::operator[](unsigned int n) { if (n >= length) throw std::exception(); return (data[n]); } template unsigned int Array::size() const { return (this->length); }