0
When I declare matrices in c++ within a class, defining "rows' and "columns" of that matrix by integer numbers directly with arguments, example [2][5] I can have the correct functioning.
However when I use variables within the matrix arguments it gives me a compilation error. (thus below)
private:
int x;
int y;
float matriz[x][y];
Error: invalid use of non-static data Member Matrix::x invalid use of non-static data Member Matrix::y
(this program I’m trying to do, is basically a matrix to represent set of real numbers).
You must set a fixed value for the matrix, unfortunately there is no way to put a "variable" with no defined value between the matrix brackets.
– Luis Faconi
Use the new operator for dynamic allocation.
– anonimo
right, how should I do that? , I haven’t had much experience with matrix.
– Vitor Gonçalves