Does anyone know if this is possible?

//in header
struct Output
{
    double *var1;
    double *var2;
    double *var3;
}

//in main
std::vector<Output> output(512);

and then be able to populate each member of the Output struct in the "output" vector?

Something like:

for (i = 0; i < 512; i++)
{
output->var1[i].push_back(value1);
output->var2[i].push_back(value2);
output->var3[i].push_back(value3);
}

If so, what is the actual syntax (since this does not work).

Thanks!

-H

for(int i = 0; i < 512; i++)
    {
        output[i].var1 = (double *)i;
        output[i].var2 = (double *)i;
        output[i].var3 = (double *)i;    
    }

shuld populate it.

Thank you zyruz!

One more question. How would I populate?

output.var1.push_back(double value); ??

Regards,

-H

if you are trying wath I think you are you need to change

struct Output
{
double *var1;
double *var2;
double *var3;
}

to

struct Output
{
std::vector<double> var1;
std::vector<double> var2;
std::vector<double> var3;
}

then can you use

output[i].var1[i].push_back(double_value);

but why not just use a vector in a vector:
std::vector< std::vector<double> > var1; ?

Okay. Thank you for the brain dump.

How would you handle a structure of mixed types then?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.