Design
Design
Array<double,2> A,B; //to store 2 dimensional array of doubles (matrix) Array<double,1> X,Y; //to store 1 dimensional array of doubles (vector) Class Members: int size[D]; // size[0] will be 1st dimension, size[1] will be 2nd dimension etc. T* data; // pointer to underlying data bool del; //flag for destructor
Constructor: Array<T,D>(); Array<T,D> E(); //Creates a D dimensional array with no elements //Constructor support for up to 2 dimensions first: Array<T,1> = X(int n); //Constructor for 1 dimension, n elements Array<T,2> = A(int m,int n); //Constructor for 2 dimensions, m*n elements Array<T,1> Y(T& k,int n); //1 Dimensional Array from k of size n Array<T,2> B(T& k, int m,int n); //2 Dimensional Array from k of size m*n Array<T,2> C= A; //Make a copy of A, there will be compile time error if A is not the same type Destructor: ~Array<T,D>();