Answer the question
In order to leave comments, you need to log in
What to take out in a separate class?
Guys, hello everyone. There is such a question, I have a program for working with a matrix, but it is implemented using one class, but I need more.
So, what would you advise to make another class in a separate class, otherwise I got confused.
Some code
I would appreciate your help.
Answer the question
In order to leave comments, you need to log in
Perhaps, if you need exactly two classes, you should create the first class in which memory is allocated for the matrix (in the constructor) and freed (in the destructor). Plus, there is a method for setting and getting a value by index.
In the second class, it is then reasonable to describe and implement methods for various types of filling the matrix and working with it.
Something like this:
class BaseMatrix
{
private:
int M, N;
int * matrix;
public:
BaseMatrix(int m, int n);
~BaseMatrix();
void SetItem(int m, int n, int x);
int GetItem(int m, int n);
}
class Matrix
{
private:
BaseMatrix * matrix;
public:
Matrix(int m, int n);
~Matrix();
void UserSet();
void AddRow();
void DelRow();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question