1 struct str 2 { 3 int age; 4 struct str a; //自引用 5 };这种自引用的是非法的,因为成员a还包含令一个完整的成员,而那个成员有包含另个完整的成员。这样将无线循环下去。1 struct str 2 { 3 int age; 4 struct str *a;//自向自身的指针 5 };这里的a是一个指针而不是一个结构,编译器在确定结构的长度之前就已经知道指针的长度,所以这种自引用是合法的。 1 typedef struct 2 { 3 int age; 4 struct STR *a; 5 } STR; 6 陷阱:这个定义将是错误的.这个声明的目. Read More
posted @ 2011-05-18 16:23 zendPger Views(165) Comments(0) Diggs(0) Edit