dev_15 <na************ @googlemail.com writes:
Hi, I'm going through some code and thought that this allocates an
array of structs but its supposed according to comments to allocate an
array of pointer to structs. What does it actually do
ptrLogArray = new structDisplayLo gData *[iCount];
It behaves as per the comments. What follows 'new' is, syntactically,
a declaration with the name missed out. If you declared this array
you'd write:
structDisplayLo gData *an_array_of_pt rs_to_structs[iCount];
now just remove the name and add 'new':
new structDisplayLo gData *[iCount];
If you thought
structDisplayLo gData *array[iCount];
should mean:
structDisplayLo gData (*array)[iCount];
(i.e. a pointer to an array of structs) rather than what it *does* mean:
structDisplayLo gData *(array[iCount]);
(an array of pointers) then you need to study the syntax a bit more.
--
Ben.