to count the depth of the tree in C++