首页 > 解决方案 > 为什么在链表中使用 struct 关键字和结构名称来创建节点的指针

问题描述

struct linklist
{
    int data;
    struct linklist *next;
}

为什么要struct linklist在前面使用*next?可以简单地创建一个指针*node

标签: c++structlinked-liststructure

解决方案


为什么我们在 '*next' 前面使用 struct linklist

您不需要在这里使用详细的类型说明符。所以我想你使用它是因为你可以。

或者您可能打算跨语言边界使用该结构,在这种情况下您使用它是因为有必要在 C 中使用它。


推荐阅读