In order to automatically check if the index of an array declared by vector<T> exceeding its boundary, we define the class "Vector" derived from "vector" and do the operator overloading as shown in Vector.h. And it works well.
However, when we need to use the 2-dimensional array, we need to write more than 5 lines in order to initialize the 2-D array, as shown in main.cpp.
My question is: is there any way to define a new class "Matrix" which enjoys the ability of "Vector" for automatically checking the array boundary. and its declaration and initialization could be as simple as:
Matrix<double> tmp;
tmp.assignName( "tmp", 3, 4, 0.00);
-----------------------------------------------------
Many thanks for the helps.
"Vector.h" and "main.cpp" could be seen in tmp.zip.
Best regards,
Herbu.
However, when we need to use the 2-dimensional array, we need to write more than 5 lines in order to initialize the 2-D array, as shown in main.cpp.
My question is: is there any way to define a new class "Matrix" which enjoys the ability of "Vector" for automatically checking the array boundary. and its declaration and initialization could be as simple as:
Matrix<double> tmp;
tmp.assignName( "tmp", 3, 4, 0.00);
-----------------------------------------------------
Many thanks for the helps.
"Vector.h" and "main.cpp" could be seen in tmp.zip.
Best regards,
Herbu.
Comment