e.g.
class Matrix {
public:
Matrix(unsigned rows, unsigned cols);
Matrix(const Matrix &);
~Matrix();
unsigned getRows() const;
unsigned getCols() const;
int getValue(unsigned row, unsigned col) const;
void setValue(unsigned row, unsigned col, int value);
private:
unsigned rows, cols;
int *data;
};
void print(const Matrix &);
Arrays are messy and unsafe. You wrap them up in a class and work from there. At the very least, you do cleanup with the destructor to avoid memory leaks.

New Topic/Question
Reply





MultiQuote






|