So let's say I have two different functions. One is a part of the BST class, one is just a helper function that will call on that Class function. I will list them out here.
sieve(BST<T>* t, int n);
this function is called like this: sieve(t,n) the object is called BST t;
I'm going to be using the class remove function within the sieve function to remove specific objects. I'm not sure what my prototype for this basic function should look like? Doing this:
sieve(BST<int> t, int n)
What happens here is everything compiles just fine, but when t.remove function is called I see no actual results. I'm assuming because it's just creating a copy or a whole other t object instead of passing the one from my main() function.
If I call the remove function (t.remove(value)) in my main function where the original object was created it removes everything properly. Once I start doing it through my sieve function I see no change when I re print it out from my main function. So my main function looks something like this:
int main ()
{
int n,
i,
len;
BST<int> t;
cin >> n;
vector<int> v(n);
srand(1);
for (i = 0; i < n; i++)
v[i] = rand() % n;
for (i = 0; i < n; i++)
t.insert(v[i]);
print_stat(t);
t.inOrder(print_data);
sieve(v,t,n);
print_stat(t);
t.inOrder(print_data);
return 0;
}
So my results end up being the same, even though my debug statements within the functions show it's actually deleting something. I'm guessing where I'm going wrong is how I am passing the t object onto the function.