So I have a class that has a protected pointer member of the following type
int *assigntoThis; // In the constructor I have initialized this to NULL.
I also have a public recursive member function of the same class with the following declaration
bool find(int* parent, std::string nameofnode, int* storeParentinThis);
The recursive function checks through child nodes and if the name of the child Node matches the string passed in as a parameter it will assign the address of parent to storeParentinThis.
This is how I call the function from another function of the same class.
bool find(root, "Thread", assigntoThis);
However, during runtime when I output the value stored in assigntoThis I get 00000000 = NULL. How do I change the value of assigntoThis inside my recursive function?
change to :
explanation:
here is a simplified version of your original code:
this is actually similar to following code:
which I think is easier to understand.
So if we want to return something from a function we must make a pointer to it or a reference to it, going backwards with examples:
Now it is easy to apply it to your case: