What is self-referencing structure in C?

前端 未结 3 559
甜味超标
甜味超标 2020-12-11 14:24
struct LinkedList  
{  
    int data;
    struct LinkedList *next;
};

In the code, within the definition of struct LinkedList there is

3条回答
  •  难免孤独
    2020-12-11 14:52

    A self-referential pointer which points to the address of whatever it is a part of. So for example,

    typedef struct node {     
       char data[30]; 
       struct node *this; 
       struct node *next; 
    } Node; 
    

    *this is a self-referential pointer if it is assigned to whatever is applied to.

    ,and

    Clearly a Cell cannot contain another cell as it becomes a never-ending recursion.

    However a Cell CAN contain a pointer to another cell.

    Refer this post as well.

提交回复
热议问题