member "Node::next" (of a friend class) is inaccessible
Solution 1:
A friend
declaration grants access of the specified class to the private members of the declaring class (ie, "that class X over there is a friend of mine, he has permission to use my private stuff").
So, by declaring Node
as a friend
inside of LinkedList
, you are granting Node
access to LinkedList
's private members, not the other way around like you want.
To let LinkedList
access Node::next
, you need to declare LinkedList
as a friend
of Node
instead:
class Node {
friend class LinkedList;
...
};