c - 链表 A 绑定(bind)到另一个 B 又绑定(bind)回 A

标签 c linked-list

//2 个由指针绑定(bind)的结构

 struct A_cust            // customer information, a double-linked list with another pointer
   {
    char cust_info [20];  // as an example
    A_cust *prevCust;     // prev customer record
    A_cust *nextCust;     // next customer record
    B_tran *point_to_B;   // to the list of transaction records
   };

 struct B_tran            // transaction records, a double-linked list with another pointer
   {
    char cust_tran [20];  // as an example
    B_tran *prevTran;     // prev customer transaction
    B_tran *nextCust;     // next customer transaction
    A_cust *point_to_A    // to the list of customer records
   };

编译器在解析“A_cust”时并不知道“B_tran” 如果我先定义“B_tran”,那么编译器就不知道“A_cust”是什么

任何想法,欧内斯特

最佳答案

在代码顶部添加以下声明

struct B_tran;

编辑:这称为前向声明,您向编译器 promise 您稍后将开始定义 B_tran。 (感谢格雷格)

关于c - 链表 A 绑定(bind)到另一个 B 又绑定(bind)回 A,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11041490/

相关文章:

c - 定义浮点常量,多少位有用?

c - 初始化堆栈时出现段错误

c - 使用 C 中的 qsort 按频率将单词排序到哈希表中

c - "search"c中的链表

java - java从链表中删除多个节点

c - 如果文件存在则搜索目录数组

java - 链表实现,在头部添加还是在尾部添加?

java - Arraylist 映射到链表节点

c - 单链表简单数据库

c - Visual Studio 使用 Consolas 打开 cmd.exe