Homework 3, A two dimensional array class.
Design, implement and test a two dimensional array class.
When you finish this homework, you should have:
- Designed the interface for a useful container.
- Implemented this container as a class.
- Tested the implementation of this container.
- Worked with dynamic memory.
Design, implement and test a two dimensional array class. This class should allocate memory at run time. Once allocated, the size of this array will never change.
You should design a useful interface for this class. As a minimum it should include:
- A constructor which takes two
size_t parameters, the number of rows and columns for the constructed array.
- An overloaded  operator. It should take two parameters, the row and column the user wishes to access and return a reference to the specified location. If either parameter is out of bounds, the function should return a reference to location 0 and print an error message. Please note, this feature requires a c++23 compiler. See this reference for way too much information. The function prototype is what you would expect.
- A means to retrieve each dimension of the array.
- Any other method required to make this a fully functional class involving dynamic memory.
You should begin by documenting the interface you wish to create. This can be in a text file or in a word document. If you choose a text file, place it in
ReadMe.txt. The word document should be called
ReadMe.docx. This should fully describe the interface and any conditions for use of the class. This document should also describe how you plan to test your code.
You should implement your code in
You should provide a working test driver to demonstrate that your class works (ie implement your test cases). In addition this should demonstrate how to use your class. If your test cases do not cover the entire interface, design more test cases.
- For now, your class should hold integers.
- Is there a difference between a two dimensional array and a one dimensional array?
A[r,c] = A+(r*columns+c)*sizeof(element) is way too low level, but should give you an idea on how to access an element.
- You should have no memory leaks.
- You should support ALL required operations for a class with dynamic memory.
- You can do this with only one call to new per instance. You do not need
row+1 calls, and an array of arrays is hard to maintain anyway.
- This homework is testing multiple items.
- Design/test design 25%
- Implementation 50%
- Test Driver 25%
- You should take this seriously. You WILL use this class in future assignments. (Think game board, world map, ...)
A single tar file containing the source code and makefile for this program.
Submit the assignment to the D2L folder Homework 3 by the due date.