Homework 3C, Templates and Exceptions.

Short Description:

Do Something

Goals

When you finish this homework, you should have:

Formal Description

Update your dynamic 2D array class from Homework 3B to use templates and exception handling.

Templates

Convert your Array2T class into a templated class. The class should be able to store any appropriate data type. You should be able to create arrays of different types, for example:
Array2T<int> a(10, 10);
Array2T<double> b(5, 5);
Array2T<char> c(20, 10);

Exception Handling

Update your class to use exceptions for error handling. You should no longer print error messages from within your array class or attempt to return a valid array location when an error occurs. Instead, allow the program using your class to handle the exception.

Your test driver should demonstrate that you can catch and handle exceptions generated by your class. For example:

Array2T a(5,5);

try {
    cout << a.at(10,20);
}
catch (const out_of_range &e) {
    cout << "Array index out of bounds: "
         << e.what() << endl;
}

Notes

Required Files

Turn in a single zip or tar file containing all files required to build your project, including:

Disclosure

I asked ChatGPT to create a draft of this assignment using the previous two. It has been moderately modified by me.

Submission

Submit the assignment to the D2L folder Homework 3C by the due date.