1

// 2 个由指针绑定的结构

 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”是什么

任何想法,欧内斯特

4

1 回答 1

3

在代码顶部添加以下声明

struct B_tran;

编辑:这称为前向声明,您承诺编译器将在B_tran以后定义。(感谢格雷格)

于 2012-06-14T21:18:19.600 回答