c++ - Declaring an array inside typedef struct -


i'm trying declare array inside typedef struct this:

typedef struct node {      node[] arr = new node[25]; }; 

but getting error saying "expected identifier" , arr "expected ';'. doing wrong? thank you

you can act this

struct node {     static const int arr_size = 25;     node* arr;     node() { arr = new node[arr_size]; }     ~node() { delete[] arr; } }; 

you re not allowed initialzie non const int varizbles inside class;


and understand, creating node variable call stack overflow ? each node contains 25 nodes each node contains 25 nodes ... etc


i think wanted this

struct node {     static const int arr_size = 25;     node* arr[arr_size]; }; 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -