#ifndef VECTOR_H #define VECTOR_H #include template class Vector { private: T** p; int hang; int lie; public: Vector(); Vector(int m, int n); Vector& operator=(const Vector& x); T* operator[](int x); void AlterElement(int m, int n, T x); ~Vector(); }; template Vector::Vector() { p = nullptr; hang = 0; lie = 0; } template Vector::Vector(int m, int n) { hang = m; lie = n; p = new T * [m]; for (int i = 0;i < m;i++) { p[i] = new T[n]; } } template Vector::~Vector() { if (p) { for (int i = 0; i < hang; i++) { delete[] p[i]; } delete[] p; } } template Vector& Vector::operator=(const Vector& x) { if (p) { for (int i = 0; i < hang; i++) { delete[] p[i]; } delete[] p; } hang = x.hang; lie = x.lie; p = new T * [hang]; for (int i = 0; i < hang; i++) { p[i] = new T[lie]; for (int j = 0; j < lie; j++) { p[i][j] = x.p[i][j]; } } return *this; } template T* Vector::operator[](int x) { return p[x]; } template inline void Vector::AlterElement(int m, int n, T x) { p[m][n] = x; } #endif // !VECTOR_H