#ifndef _BOXCHARPTR_HPP_ #define _BOXCHARPTR_HPP_ #include "Box.hpp" #include template <> class Box { char *e; public: Box(); Box(char *e); ~Box(); Box(const Box& b); char* get() const; void set(char *e); Box& operator=(Box& b); friend std::ostream& operator<<(std::ostream& out, const Box& t); }; Box::Box() { this->e = nullptr; } Box::Box(char *e) { this->e = new char[strlen(e)+1]; strcpy(this->e, e); } Box::Box(const Box& b) { this->e = new char[strlen(b.e)+1]; strcpy(this->e, b.e); } Box::~Box() { delete [] this->e; } char* Box::get() const { char *ce = new char[strlen(e)+1]; strcpy(ce, e); return ce; } void Box::set(char *e) { if(this->e!=nullptr) delete [] this->e; this->e = new char[strlen(e)+1]; strcpy(this->e, e); } Box& Box::operator=(Box& b){ set(b.e); return *this; } std::ostream& operator<<(std::ostream& out, const Box& t) { out << t.e; return out; } #endif