Answer the question
In order to leave comments, you need to log in
Implement class in C++, matrices
There are matrix programs (each separate) in C++, such as - addition / subtraction, multiplication, transposition, inverse matrix. We need to get them into the classroom.
With OOP, just started. But the finished class must be handed over in 3 days. Help to implement the class, at least a few lines on the design of the code (methods and their arguments (I can write the implementation of the method myself), etc.)
Please help.
Answer the question
In order to leave comments, you need to log in
#include <stdexcept>
using namespace std;
class Matrix
{
protected:
double *matrix;
unsigned size_x, size_y;
public:
Matrix()
{
matrix = NULL;
size_x = size_y = 0;
}
Matrix(unsigned sz_x, unsigned sz_y)
{
matrix = new double[sz_x * sz_y];
size_x = sz_x; size_y = sz_y;
}
/** Во всех операциях, где участвуют две матрицы нужно проверять их совместимость по размеру **/
Matrix& operator+(Matrix &b)
{
}
Matrix& operator-(Matrix &b)
{
}
Matrix& operator*(Matrix &b)
{
}
double* operator[](unsigned index)
{
if(index > sz_y)
throw out_of_range("Index is out of range");
return &matrix[index * sz_x];
}
Matrix& transpose()
{
}
Matrix& reverse()
{
}
};
double get(unsigned i, unsigned j) {}
. If this is not so important, then you can do it as indicated.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question