template <class T> class array { public: explicit array(size_t size) : size_(size) { p_data_ = new T[size + 1]; if(NULL != p_data_){ memset(p_data_, 0, (sizeof(T) * (size + 1))); } } array(const array<T>& oth) { p_data_ = new T[size + 1]; if(NULL != p_data_){ memcpy(p_data_, oth.p_data_, (sizeof(T) * (size + 1))); } } ~array(){ if (NULL != p_data_) { delete[] p_data_; p_data_ = NULL; } } T& operator*() { return *p_data_; } T* operator->() { return p_data_; } /* const T& operator[](size_t i) const { return p_data_[i]; } T& operator[](size_t i) { return p_data_[i]; } */ operator T*(void) { return p_data_; } operator const T*(void) const { return p_data_; } operator bool(void) const { return (NULL != p_data_); } private: array<T>& operator=(const array<T>&); size_t size_; T *p_data_; };