S
sophie
Hi, I have been asked for an exam question to implement the
constructor, copy constructor and destructor for the following class
that describes an n-by-n matrix containing n squared integer values.
(Eg. a matrix of n rows and n colums):
import <iostream.h>
class myMatrix
{
private:
int **data; //pointer to array of n pointers, which in turn point to n
arrays that contain matrix data
int size; //size of matrix
public:
//contructor, matrix elements are initialized with defaultValue
myMatrix(int matrixSize, int defaultValue);
//copy constructor
myMatrix(const myMatrix &v);
//destructor
~myMatrix
};
I'm a bit lost on what "int **data" is. How do you actually use this to
create the constructor? I didn't even know you could declare something
like that. Hopefully someone can sort me out here??? Thanks!!!
constructor, copy constructor and destructor for the following class
that describes an n-by-n matrix containing n squared integer values.
(Eg. a matrix of n rows and n colums):
import <iostream.h>
class myMatrix
{
private:
int **data; //pointer to array of n pointers, which in turn point to n
arrays that contain matrix data
int size; //size of matrix
public:
//contructor, matrix elements are initialized with defaultValue
myMatrix(int matrixSize, int defaultValue);
//copy constructor
myMatrix(const myMatrix &v);
//destructor
~myMatrix
};
I'm a bit lost on what "int **data" is. How do you actually use this to
create the constructor? I didn't even know you could declare something
like that. Hopefully someone can sort me out here??? Thanks!!!