二叉树
#include <iostream>
using namespace std;
template <typename t> class tree;
template <typename t> class knot
{
friend class tree <t>;
public:
t data;
class knot<t>* left;
class knot<t>* right;
knot();
knot(t a) { data = a; }
void set(t a) { data = a; }
void setleft(knot<t> zuo) { left =& zuo; }
void setright(knot<t> you) { right=&you; }
};
template <typename t> class tree
{
public:
class knot<t>* root;
tree() { root = NULL; }
tree(knot<t> a) { root =& a; }
bool isempty() { if (root == NULL)return true; else return false; }
t visit(knot<t> *a) { cout << a->data; return a->data; }
};
int main()
{
class knot<int> a(5), b(10);
class tree<int> x(a);
x.root->setleft(b);
int c = x.visit(x.root->left);
}