c++ - Create a array of structs but define the size later? -
i'm trying create array of structs, define it's size later, so:
struct xy{ int x; int y; }; int main(){ xy pos; int size = 10; pos = new xy[size]; pos[0].x = 5; } but can't work no matter try. don't want use vector this, please don't should.
new returns pointer:
int main(){ xy* pos; int size = 10; pos = new xy[size]; pos[0].x = 5; }
Comments
Post a Comment