Problem

(Overloading the Parentheses Operator) One nice example of overloading the function call o...

(Overloading the Parentheses Operator) One nice example of overloading the function call operator () is to allow another form of double-array subscripting popular in some programming languages. Instead of saying

chess Board [row] [column]

for an array of objects, overload the function call operator to allow the alternate form

chess Board ( row, column )

Create a class Double Subscripted Array that has similar features to class Array in Fig 1-2. At construction time, the class should be able to create a Double Subscripted Array of any number of rows and columns. The class should supply operator () to perform double-subscripting operations. For example, in a 3-by-5 Double Subscripted Array called chess Board, the user could write chess Board (1, 3) to access the element at row 1 and column 3. Remember that operator () can receive any number of arguments. The underlying representation of the Double Subscripted Array could be a single-subscripted array of integers with rows * columns number of elements. Function operator () should perform the proper pointer arithmetic to access each element of the underlying array. There should be two versions of operator ()-one that returns int&(so that an element of a Double Subscripted Array can be used as an lvalue) and one that returns int. The class should also provide the following operators: ==, !=, =, << (for outputting the Double Subscripted Array in row and column format) and>> (for inputting the entire Double Subscripted Array contents).

Fig 1. Array class definition with overloaded operators. (Part 1 of 2.)

Fig 1. Array class definition with overloaded operators. (Part 2 of 2.)

Fig 2. Array class member- and friend-function definitions. (Part 1 of 3.)

Fig 2. Array class member- and friend-function definitions. (Part 2 of 3.)

Fig 2. Array class member- and friend-function definitions. (Part 3 of 3.)

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 11
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT