Self referring structure declaration

前端 未结 7 727
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 04:00

The follwing declaration is valid.

struct node
{
    int a;
    struct node *next;
};

However, when we define the following, it gives error.

7条回答
  •  无人及你
    2021-01-21 04:20

    Pointer store address, struct has structure. If declared like struct it would be recursive and infinite. If declared like pointer it refers to other structure somewhere else.

提交回复
热议问题