I have a class, and part of the input to the class is a vector (called Data) of variable length (say, it has length N). I included this after the function:
N = data_->size();
In the private section of the class, I want to declare an array double A[N][N];. However, when I try to do this, I get something saying
error: "N is not a type name, static, or enumerator."
How to create an array A[N][N]?
Sorry if this has already been explained elsewhere, as I am very new to C ++, so I donโt even know what to look for!
Edit - nested code:
class foo {
public:
foo (std::vector &data)
: data(data_)
{
N = data_->size();
M =
}
private:
double A[M][M];
void foo(void)
{
for (std::size_t i=1; i<=M; ++i)
{
A[i][i] = 1;
}
}
};
Hope this makes some sense ... How could I define A [M] [M]? Perhaps this cannot be done for M, since M is a data function. If this is not possible for M, is it possible that N?
, , A a std::vector< std::vector<double> > A, 0 - , THEN ...