Can someone help me finding that why this code is not working as expected?

Code:#include <iostream> #include <cstdlib> using namespace std; struct Node { int item; Node *left; Node *right; }; class Tree { Node *root; public: Tree() { root = new Node; root->left = 0; root->right = 0; root->item = 0; } void insert(int i) { ins(i, root); } void inorder() { in(root); } private: void ins(int i, Node *r) { if (!r) { r = new Node; r->left = r->right = 0; r->item = i; } else { if (r->item > i) ins(i, r->left); else if (r->item < i) ins(i, r->right); } } void in(Node *r) { if (r) { in(r->left); cout << r->item << ' '; in(r->right); } } }; int main() { Tree t; for (int n=1; n<=10; ++n) { t.insert(rand() % 100); } t.inorder(); return 0; }