V
vduber6er
Lets say I have this structure:
typedef struct numbers {
double first = 0.0;
double second = 0.0;
double third = 0.0;
} MYVALUES;
and I initialize an array of MYVALUES like the following
MYVALUES * foo;
foo = new MYVALUES [3];
I would expect the following initial values from foo:
foo[0].first == 0.0
foo[0].second == 0.0
foo[0].third == 0.0
foo[1].first == 0.0
foo[1].second == 0.0
foo[1].third == 0.0
foo[2].first == 0.0
foo[2].second == 0.0
foo[2].third == 0.0
My question is, how does the compiler initialize these values? Does it
run a loop to initialize foo kinda like this?
for (i=0; i<3; i++){
foo.first = 0.0;
foo.second = 0.0;
foo.third = 0.0;
}
I can't have it run a loop because my array can potentially be very
large and i don't want it to take up processing time.
Thanks
Eric
typedef struct numbers {
double first = 0.0;
double second = 0.0;
double third = 0.0;
} MYVALUES;
and I initialize an array of MYVALUES like the following
MYVALUES * foo;
foo = new MYVALUES [3];
I would expect the following initial values from foo:
foo[0].first == 0.0
foo[0].second == 0.0
foo[0].third == 0.0
foo[1].first == 0.0
foo[1].second == 0.0
foo[1].third == 0.0
foo[2].first == 0.0
foo[2].second == 0.0
foo[2].third == 0.0
My question is, how does the compiler initialize these values? Does it
run a loop to initialize foo kinda like this?
for (i=0; i<3; i++){
foo.first = 0.0;
foo.second = 0.0;
foo.third = 0.0;
}
I can't have it run a loop because my array can potentially be very
large and i don't want it to take up processing time.
Thanks
Eric