Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linked List implementation with structures or class?

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.


1 Answers

He wanted the default access to be public - that's the only difference between classes and structures in C++

like image 53
Nemanja Trifunovic Avatar answered May 27 '26 17:05

Nemanja Trifunovic