jeudi 8 avril 2021

How to use unique pointers to create matrix?

I have to create a matrix using unique poiters that permit operations: Matrix a,b; Matrix c(b) and Matrix d=a; So far I did the simple implementing of a matrix

class Matrix
{
public:vector<vector<int>> data;
    Matrix() {}
    Matrix(vector<vector<int>> matrix)
    {
        this->data=matrix;
    }
    Matrix (const Matrix& m2)
    {
        this->data=m2.data;
    }
    Matrix& operator= (const Matrix &m2)
    {
        this->data = m2.data;
        return *this;
    }
}

It's first time for me facing unique_ptr vectors, I found a plenty of informations about unique_ptr vectors creating arrays, but not much for matrix, it's so unclear. How can I use unique_ptr vectors(I must use them) instread of simple vector? Any help is welcome, thank you!

Aucun commentaire:

Enregistrer un commentaire