I am starting data structures in C++ and while reading, I came up to the following snippet,
template <class Node_entry>
struct Node {
// data members
Node_entry entry;
Node<Node_entry> *next;
// constructors
Node( );
Node(Node_entry, Node<Node_entry> *link = NULL);
};
Can anyone please elaborate why the author choose a structure and not a class for the implementation of the singly linked list? Thanks.
He wanted the default access to be public - that's the only difference between classes and structures in C++
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