-4
在我的BST模板类中,有一个不带参数的PrintInOrder()
函数。二叉搜索树 - PrintInOrder();
void BST<Type>::printInOrder() const{}
我看到了一些功能,他们都采取了Node*
根作为参数,这是有道理的。
如何使用引用的函数来进行递归打印所有的值?
代码:
/* I don't know if it's gonna help, but this is my class */
struct Node
{
Type m_data;
Node *m_left, *m_right;
Node(const Type& _data) : m_data(_data), m_left(nullptr), m_right(nullptr) {}
};
Node* m_root;
int m_size;
public:
BST();
~BST();
BST& operator=(const BST& that);
BST(const BST& that);;
void insert(const Type& v);
bool findAndRemove(const Type& v);
bool find(const Type& v) const;
void clear();
void printInOrder() const;
};
可能重复[Inorder Traversal with Recursion?](http://stackoverflow.com/questions/20034335/inorder-traversal-with-recursion) –
他的函数传递一个根作为参数。我试图找出一个不带参数的函数 – jcsantos