#includeusing namespace std;
templateclass Matrix{public: Matrix(int row, int col) :m_row(row), m_col(col), m_data(nullptr) { m_data = new T[m_row * m_col]; } ~Matrix() { if (m_data != nullptr) { delete[] m_data; m_data = nullptr; } } // 返回二维数组的第 k 行地址,注意加上 const 因为数组地址是不可变的 T * const operator[](int k) { cout<<"times"<
int main(){ Matrix m2(3, 4); m2[0][0] = 2; /*m2[2][3] = 9; cout << m2[0][0] << endl; // 2 cout << m2[2][3] << endl; int number=10; int* const ptr=&number; *ptr=20; cout<<*ptr<