ex02 starting
This commit is contained in:
54
ex02/Array/Array.tpp
Normal file
54
ex02/Array/Array.tpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Array.tpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/03/21 17:09:36 by aortigos #+# #+# */
|
||||
/* Updated: 2026/03/21 17:11:51 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
template <typename T>
|
||||
class Array
|
||||
{
|
||||
private:
|
||||
T *element;
|
||||
unsigned int size;
|
||||
public:
|
||||
Array()
|
||||
{
|
||||
new T[n]();
|
||||
}
|
||||
|
||||
Array(const Array &other)
|
||||
{
|
||||
if (this != other)
|
||||
{
|
||||
this->element = other.element;
|
||||
this->size = other.size;
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
Array& operator=(const Array &other)
|
||||
{
|
||||
this = other;
|
||||
}
|
||||
|
||||
~Array()
|
||||
{
|
||||
delete[] T;
|
||||
}
|
||||
|
||||
Array(unsigned int n)
|
||||
{
|
||||
this->size = n;
|
||||
}
|
||||
|
||||
int size()
|
||||
{
|
||||
return (this->size);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user