#include "stdafx.h" #include using namespace std; class leaf { public: int node; int height_left, height_right; leaf *left,*right; leaf(int x) { node=x; left=right=NULL; height_left=height_right=0; cout << "leaf(int x) worker " << endl; } leaf* add_leaf(int x) { cout << "add_leaf(leaf *t, int x) worker " << endl; if (this==NULL) return new leaf(x); if (xadd_leaf(x); else left=left->add_leaf(x); else if (right) right->add_leaf(x); else right=right->add_leaf(x); return this; } void view() { if (left) left->view(); cout<view(); } }; int _tmain(int argc, _TCHAR* argv[]) { leaf* root=NULL; for (int i = 0; i < 10; ++i) root=root->add_leaf(10-i); root->view(); return 0; }