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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -