Why can't a struct be a member of itself?

后端 未结 3 1597
鱼传尺愫
鱼传尺愫 2021-01-23 03:24

I have a struct foo. Declaring a member of type foo* works:

typedef struct foo
{
    struct foo* children[26];
} foo;

3条回答
  •  长情又很酷
    2021-01-23 04:05

    1. Object of type T can't contains another non-static object of same type. If it may be possible, how to find size of that object? Size of pointer to object is always constant on current system.
    2. Check value of currentptr for non-NULL before you can access fields of currentptr (like is_endpoint).

提交回复
热议问题