I am creating a binary tree header file, but only using class (not struct). This is what I have but I get an error and I don't understand how to fix it. Error:
Main.cpp: In function `int main(int, char **)':
BinaryTree.h:21: `class binaryTree::node * binaryTree::root' is private
Main.cpp:12: within this context
BinaryTree.h:21: `class binaryTree::node * binaryTree::root' is private
Main.cpp:15: within this context
Code:
using namespace std;
#ifndef BINARYTREE_H
#define BINARYTREE_H
class binaryTree
{
private:
class node
{
public:
int data;
node *left;
node *right;
void addNode(int key, node *n);
};
node *root; // the root
void inorder(node *n);
void binaryTree::addNode(int key, node *n);
public:
void addNode(int key);
int getHeight(node *n);
node getRoot();
binaryTree();
binaryTree(int data);
};
#endif