Compilation error-field has incomplete type

error: field `next' has incomplete type

struct node{ 
    struct node next; 
    int data; 
};

 
Why a pointer? 


Consider this: the point of a struct definition is so that the compiler can figure out how much memory to allocate and what parts to access when you say node.data. If your node struct contains another node struct, how much memory should the compiler allocate for a given node.

No comments:

Post a Comment