Good evening. I'm thinking about the vector library and one of the utilities that I see is great is that you can create a vector that is a variable
Example:
int main()
{
int a=5;
vector<double> vec(a,0);
}
That would be equivalent to doing:
vec[a];
Sentence is forbidden in C ++.
My doubt is that I do not find a similar idea to extend this concept to matrices like this example
int main()
{
int a=3;
int b=4;
int resultado;
resultado=suma(a,b);
//Crear una matriz a partir de estos resultados tipo m[resultado][a];
}
int suma(int a, int b)
{
return(a+b);
}
I know I could use "new" but the question is if there is another possibility of the same style as "vector". I have looked at CPPreference but I have not found what I'm looking for.
Greetings.
EDIT:
After this question I have another totally different one:
Imagine that I am running a function and there comes a time when I get a series of dynamic arrays and I want to return one of them. Example:
[...]
a=[1,1]
b=[2,2]
[...]
resultadovec=[1,1,2,2]
resultadomat=[1,1;2,2]
Can I pass this result to the main function? Keep in mind that the dimensions and values of this array (vectors and matrices) I have obtained in this function after several calculations. I think that it can not be done directly but I would like to confirm it. The idea if you can not finally return the size of the vector and matrix that can generate, create that vector and matrix (here comes the previous doubt) and then execute the function again (its second part) so that I return values numerics.