How can i dynamic allocate memory for a matrix with rows and columns parameters given by the user? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i dynamic allocate memory for a matrix with rows and columns parameters given by the user?

5th Apr 2018, 2:01 PM
Bruno Ribeiro
Bruno Ribeiro - avatar
2 Answers
+ 1
#include <vector> template <typename T> using matrix = std::vector<std::vector<T>>; Let the vector class do it for you.
5th Apr 2018, 2:06 PM
Timon Paßlick
+ 1
thanks a lot !
5th Apr 2018, 2:31 PM
Bruno Ribeiro
Bruno Ribeiro - avatar