Homework 3A, A 2D Array Class.
Short Description:
Implement a 2D array class.
Goals
When you finish this homework, you should have:- Implemented and tested a static 2D array class.
Formal Description
Implement a static 2D array class. This should be calledArray2T. It should hold up to 100 x 100 elements, of type DataT, which you will alias in your header file to be an integer type.
This class should be implemented in Array2T.h and Array2T.cpp. You should also supply a test driver (testDrive.cpp) that will test all methods completely.
You should support the following methods
- Construct the default array.
- Construct an array of given dimensions
- Get the number of rows (as allocated).
- Get the number of columns (as allocated).
- Overloaded [] operators for both the right hand and left hand side. These should not perform bounds checks.
- Overloaded
atfunction for both the right and left hand side of an equation that perform bounds check.
at and [] should take two size_t parameters, rows and columns. To do this, you will need to use at least c++23. For the at operator, if the array indexes are out of bounds, print an appropriate error message and return position (0,0).
You should support the following code snippet:
Array2T a;
cout << a[10,20];
cout << a.at(10,20);
a[1,2] = 5
a.at(1,2) = 5
Since we do not have dynamic array yet, you will need to declare a static array, and keep track of:
- The user requested rows and columns
- The capacity rows and columns.
Notes
We will be containing to work on this for the next few assignments.
Your code must compile without warnings or errors on prog1 with the following flags: -Wall -Wextra -Wpedantic -Wshadow -Wconversion -std=c++23 -g -O2