I was working on a homework assignment and I stumbled upon a roadblock
I created a linked list class that looks something like this
List.h
class List{
struct Node{
string data
etc...
}
public:
Node* lastNode(Node* root);
List.cpp
#include "List.h"
List::Node* lastNode(Node* root){
while(root && root->next){
root = root->next;
}
return root;
}
When I try to run the code, it says "struct List::Node is private" within this context (starting with the function header for lastNode in List.cpp)
I'm not understand what's causing this. I know that private fields can only be accessed by member functions of the same class, but isn't lastNode a member function?