By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,548 Members | 1,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,548 IT Pros & Developers. It's quick & easy.

self referential structure

P: 1
struct node
int data;
struct node *link;

How come it does not throw an error when it encounters struct node *link when the declaration is not yet complete ?

May sound silly... still i wanted to ask.. Some body knows this ???
Jun 12 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
It's because the compiler has already seen struct node. That's enough information for the compiler to know that such a struct exists. Therefore, it is acceptable to have a pointer to a variable of that type.
Jun 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.