So we got a homework to count nodes in binary search tree but we are not allowed to use global variables or function parameters since we get a pre made template which we shouldn't change. I know how to do that with global variable and function parameter, but I don't know how to do that without it since I can't use local variable.
My code now:
int count() const
{
int st = 1;
if (left != NULL) {
st++;
left->count();
}
if (right != NULL) {
st++;
right->count();
}
return st;
}