iphone - C++ Struct in array, help! -
i have iphone app used use array of several thousand small objects data source. now, trying make use c++ structs, improve performance. have written struct, , put in "particle.h":
typedef struct{ double changex; double changey; double x; double y; }particlestruct;
then, imported "particle.h", , attempted define array:
#import "particle.h" @implementation particledisplay struct particlestruct particles[]; ///size determined later, declaration make ////the declaration visible entire class...
on line, however, error: "array type has incomplete element type". else compiles fine, far can tell, , sure "particle.h" has been imported before declaration. ideas?
since have typedef
ed in particle.h, drop word struct
array declaration line (the line error is).
however,
in c++, not need
typedef
it, writestruct particle { /* members */ };
why declaring array without length? consider using
std::vector
(tutorial) dynamically re-sizeable array (you don't have bother length ever). simple as:std::vector< particle > particles;
Comments
Post a Comment