Reputation: 351
VS is not happy with the "Node*" argument for "makeEmptyHelper" because it does not 'see' the struct I guess.
public:
void makeEmpty(); // make the tree empty so isEmpty returns true
void makeEmptyHelper(Node*);
private:
struct Node {
NodeData* data; // pointer to data object
Node* left; // left subtree pointer
Node* right; // right subtree pointer
};
Node* root; // root of the tree
Upvotes: 0
Views: 101
Reputation: 844
You can't do that. I see two possible things you're trying to accomplish:
Have makeEmptyHelper
be accessible publicly but hide the contents of struct Node
. In that case, you should either declare the fields of struct Node
as private, or declare struct Node
as public but only define its members in your implementation file.
Have makeEmptyHelper
be a helper function for another member function. In that case, make it private.
Upvotes: 1
Reputation: 538
The Node struct is an argument of a public method of your class.
Therefore the Node struct is something that will be public outwards.
So the Node struct shall be public.
Upvotes: 0
Reputation: 77285
That's correct. You cannot have a function publicly available while it's argument is private. Either make the type of the argument public as well or make the method private.
Upvotes: 1