J
Jim
Hi,
I want to declare that that a valarray of a certain name exist at the
beginning of some code, but I can't instatiate it until I've read in
some parameters later on in a for loop i.e.
int main(int argc, char * argv[])
{
valarray<float> data;
float init=0;
for(int i=0; i<argc; i++)
{
//read in parameters, ax1,ax2
valarray<float> d(init,ax1*ax2); //***
data=d;
}
}
Problem is when the code leaves the for loop data is of size 0, as
what it's pointed to has been deleted by passing out of scope. I've
tried all sorts of combinations data as extern, defining it outside
the main block, replacing *** with data(init,ax1*ax2); but no success.
If anyone's got any ideas I would be very grateful!
Thanks
I want to declare that that a valarray of a certain name exist at the
beginning of some code, but I can't instatiate it until I've read in
some parameters later on in a for loop i.e.
int main(int argc, char * argv[])
{
valarray<float> data;
float init=0;
for(int i=0; i<argc; i++)
{
//read in parameters, ax1,ax2
valarray<float> d(init,ax1*ax2); //***
data=d;
}
}
Problem is when the code leaves the for loop data is of size 0, as
what it's pointed to has been deleted by passing out of scope. I've
tried all sorts of combinations data as extern, defining it outside
the main block, replacing *** with data(init,ax1*ax2); but no success.
If anyone's got any ideas I would be very grateful!
Thanks