这题不要出,它是6.1题的一部分
Design a template class Matrix that has the following private member variables:
int rows
int columns
T * values
, where T is the type parameter.
Besides, it has the following public functions:
A constructor Matrix(int rows, int column), which initializes all elements in the matrix to all 0's.
A destructor.
A print function which prints each row of elements in a single line, with each element preceded with 4 spaces.
EXAMPLE INPUT
3 4
EXAMPLE OUTPUT
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
主程序 (不能修改)
#include "source.cpp"
int main() {
int rows;
int columns;
cin >> rows >> columns;
Matrix<double> matrix1(rows, columns);
matrix1.print();
cout << endl;
Matrix<int> matrix2(rows, columns);
matrix2.print();
}
我的答案