SHARE
HELP

To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

Authors:
Walter Savitch ,kenrick Mock
Chapter:
Pointers And Dynamic Arrays
Exercise:
Programming Projects
Question:1 | ISBN:9780132846813 | Edition: 5

### Question

Reread the code in Display 10.9 . Then, write a class TwoD that implements the two-dimensional dynamic array of double s using ideas from this display in its constructors. You should have a private member of type pointer to double to point to the dynamic array, and two int (or unsigned int ) values that are MaxRows and MaxCols.

You should supply a default constructor for which you are to choose a default maximum row and column sizes and a parameterized constructor that allows the programmer to set maximum row and column sizes.

Further, you should provide a void member function that allows setting a particular row and column entry and a member function that returns a particular row and column entry as a value of type double.

Remark: It is difficult or impossible (depending on the details) to overload [ ] so it works as you would like for two-dimensional arrays. So simply use accessor and mutator functions using ordinary function notation.

Overload the + operator as a friend function to add two two-dimensional arrays. This function should return the TwoD object whose i th row, j th column element is the sum of the i th row, j th column element of the left-hand operand TwoD object and the i th row, j th column element of the right-hand operand TwoD object. Provide a copy constructor, an overloaded operator = , and a destructor. Declare class member functions that do not change the data as const members.

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.