3
My BST (templated class) has function PrintInOrder()
, that does not receive parameters:
void BST<Type>::printInOrder() const{}
I’ve been looking on the Internet, and I found some InOrder()
, but they get a Node*
for the root as parameter, which makes sense.
How could I make a recursion in the function I quoted without passing parameters?
There’s a way I can create a private member in class to help with that?
My BST 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;
};
What you can do is create a private method that needs parameter (and implement it recursively) and in your public method you call this private by passing the
m_root
– Berriel