有关指针的前向参考?

时间:2013-02-02 07:10:01

标签: c pointers

  

可能重复:
  What is forward reference in C?

我在某处读到了这个问题

"What is forward reference with respect to pointers in C, and what are its advantages"

此处提到的接受答案:What is forward reference in C? 没有给出正确的解释? 任何人都可以解释它究竟意味着什么它有什么优势吗?

1 个答案:

答案 0 :(得分:2)

前向引用wrt指针是我们使用的术语,

声明指针,编译器为指针保留内存,但未定义指针指向的DataItem。

来自之前的答案::

struct MyStruct *ptr; // this is a forward reference cuz pointer ptr is declared
                      // but the structure it points to is itself not defined till now.

struct MyStruct // Now the structure is declared
{
       // some data members
};

优点:: Advantages