-
Notifications
You must be signed in to change notification settings - Fork 0
/
Array2D.h
60 lines (44 loc) · 1.57 KB
/
Array2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**************************************************************
* Author: Keyul Patel
* Date Created: 10/10/15
* Last Modification Date: 10/11/15
* Lab Number: CST 211 Assignment 2
* Filename: Array2D.h
*
*
* Overview: A tempmlated 2D array
*
* Input: A number of rows and columns
*
* Output: none
****************************************************************/
#include "exception.h"
#include "Row.h"
using namespace std;
#ifndef Array2D_h
#define Array2D_h
template <class T>
class Array2D
{
public:
Array2D(); // Default Constructor
Array2D(int row, int col); // Constructor for the 2D array
Array2D(const Array2D ©); //Copy Constructor
~Array2D(); //Destructor
Array2D &operator=(const Array2D &rhs); //= Operator Overload
Row<T> operator[](int index); //[] Operator Overload
Row<T> operator[](int index) const; //[] Operator Overload for const
int getRow() const; //Returns the number of rows
void setRow(int rows); //Changes the number of rows
int getColumn() const; //Returns the number of colums
void setColumn(int columns); //Changes the number of columns
T &Select(int row, int column) const; //Used to select an element in the 2D array object
private:
T **m_array; // Pointer to an array of the data type that will be allocated
int m_rows; // Number of rows
int m_cols; // Number of columns
void create_array(T **&new_array, int rows, int cols); //Used to allocate data for new arrays
void array_transfer(T **new_array, int rows, int cols, bool conserve); //Used to conserve and transfer data between 2D arrays
};
#include "Array2D.inc"
#endif