0

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

Edited by pyTony: fixed formating

3
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by bumsfeld
0
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.

0

Thank you zyruz!

One more question. How would I populate?

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

Regards,

-H

0

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; ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.