Can I use local static vairable as shown below to allocate dynamic memory. I tried this but the compiler is giving error that the
[error] expected type specifier before static.
1 2 3 4 5 6 7 8 9 10 11 12 13
staticdouble **aP_u = NULL;
aP_u = newstaticdouble *[N];
for (i = 0; i < N; i++)
{
aP_u[i] = newstaticdouble[N];
}
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
aP_u[i][j] = 0.0;
}
}
Actually this I am using inside a function, to be also used in the main function.
However can I use this dynamic memory allocation in main function to use in void function used inside of main?
// some function
{
// an NxN matrix of double, initialised to all zeroes, with static storage duration
static std::vector< std::vector<double> > aP_u( N, std::vector<double>(N) ) ;
// ..
}