self referential struct definition?

后端 未结 9 1747
死守一世寂寞
死守一世寂寞 2020-11-22 11:09

I haven\'t been writing C for very long, and so I\'m not sure about how I should go about doing these sorts of recursive things... I would like each cell to contain another

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 11:48

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

    However a Cell CAN contain a pointer to another cell.

    typedef struct Cell {
      bool isParent;
      struct Cell* child;
    } Cell;
    

提交回复
热议问题