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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -