struct node
{
int data;
struct node *next;
}*start;
I don't understand what struct node *next does, I know it points to the address of the next variable; but how as in implementation? Is node *next similar to struct node *next?
And what about the *start is it similar to struct node *start?
I am finding very difficulty understanding linked lists implementation.
I don't understand what
struct node *nextdoes, I know it points to the address of the next variable; ...
This is correct.
... but how as in implementation ?
The implementation is pretty much exactly how you described the behaviour: A pointer is implemented as an object whose value is the memory address of the pointed object.
Is
node *nextsimilar tostruct node *next?
Not only similar, but pretty much identical.†
And what about the
*startis it similar tostruct node *start?
It is struct node *start. See the complete declaration:
struct node /* structure definition */ *start;
It is a combined declaration of a variable, and definition of a structure.
† The struct keyword is just used to disambiguate that the following identifier is in the name space†† of structure tags. In your case it is redundant, because there are no non-structure identifier Node to disambiguate, and in C++ structure tags are also type names.
What you're probably looking at is C code, where the name space†† specifier is mandatory for structure tags.
†† In this context, I refer to C name spaces, not C++ name spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With