1
0
This repository has been archived on 2025-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
CPP_Module_04/ex03/MateriaTemplate.hpp

59 lines
1.9 KiB
C++
Raw Permalink Normal View History

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* MateriaTemplate.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/11 10:59:31 by adjoly #+# #+# */
/* Updated: 2024/12/11 12:06:51 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "AMateria.hpp"
#include "Log.hpp"
template <typename T>
class MateriaTemplate : public AMateria {
public:
MateriaTemplate(void);
~MateriaTemplate(void);
MateriaTemplate(T const &);
T &operator=(const T &);
AMateria *clone(void) const;
};
template <typename T>
MateriaTemplate<T>::MateriaTemplate(void) :
AMateria(T::_typeName()) {
log("", T::_typeName(), "", "default constructor called");
}
template <typename T>
MateriaTemplate<T>::~MateriaTemplate(void) {
log("", T::_typeName(), "", "destructor called");
}
template <typename T>
MateriaTemplate<T>::MateriaTemplate(T const &cpy) {
*this = cpy;
log("", T::_typeName(), "", "copy constructor called");
}
template <typename T>
T &MateriaTemplate<T>::operator=(const T &cpy) {
log("", T::_typeName(), "", "copy assignement constructor called");
if (this != &cpy) {
this->_type = cpy._type;
}
return (*this);
}
template <typename T>
AMateria *MateriaTemplate<T>::clone(void) const {
return (new T);
}