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

后端 未结 3 1594
鱼传尺愫
鱼传尺愫 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 03:57

    The structure Trie cannot contain another structure Trie in it , it will do a never - ending recursion but it may contain a pointer to another structure Trie

    So first one is correct

    typedef struct TRIE
    {
        bool is_endpoint;
        bool is_initialized;
        struct TRIE* children[26];
    } TRIE;
    

提交回复
热议问题