# Message from C, C++ discussions

December 2019

— Now I want to create a method sum, to sum 2 Matrixes(with the same dimensions) , the method must to do with pointers and must return a pointer, Matrix3D* sum(Matrix3D* m1, Matrix3D* m2) , but how can I select every element of m1 and m2 and put the sum in mat_sum?

Https://pastebin.com/A6w8fJUY this is the code that I wrote but I don't know what I should put in the FOR to select the elements,to sum and to put in mat_sum

— Why are you using dynamic allocation for the sum

— I must return a pointer

— Matrix3D* mat_sum

— Can I see the header file pls

— Okay

— Ty

— Https://pastebin.com/z8hbe1Ri

—

Matrice3D Matrice3D::sum(const Matrice3D& m1, const Matrice3D& m2) {

Matrice3D mat_sum{};

for(int i=0;i<a;i++)

for(int j=0;j<b;j++)

for(int h=0;h<c;h++){

//Add

}

return mat_sum;

}

— Without extra dynamic allocation

— The exercise is do this sum with pointers. And in Add I didn't get what I must do