Hi All,
We know what is self-referential structure and it is widely used in creating data structure (for ex: linked-list)
struct xxx
{
int a;
struct xxx *ptr;
}
Why should I declare "ptr" to be of the same type. Cannot I declare "ptr" as "int" or "void" as it is going to store only the address.
I searched net, but most of the pages explain self-referential structure but I could not find the reason.
Thanks & Regards
Sathish Kumar
We know what is self-referential structure and it is widely used in creating data structure (for ex: linked-list)
struct xxx
{
int a;
struct xxx *ptr;
}
Why should I declare "ptr" to be of the same type. Cannot I declare "ptr" as "int" or "void" as it is going to store only the address.
I searched net, but most of the pages explain self-referential structure but I could not find the reason.
Thanks & Regards
Sathish Kumar
Comment