The simple answer is that information is transferred from the function to the caller using it's return value.
In your code, the treeForm() function returns an int. When main() calls treeForm(), it will get an int back. What you do with that int is up to you.
There are other ways functions can manipulate data, but save that till later.
I'm also getting an error when I try to compile telling me that there's multiple definitions of my function treeForm() but it's only listing the one instance of it.
Few things to note in main()
1 2 3 4 5 6 7 8
|
#include "src/treedata.cpp"
int main()
{
int treeForm(); // remove this line
treeForm(); // treeForm() returns an int, where's it going?
}
|
1) Remove line 5 completely. That line is declaring a function named treeForm(), which can't be done in main or any other function. You've already declared it in datatree.cpp.
2) Line 7 calls the treeForm() function which is great. However, it doesn't do anything with the int that treeForm() returns. You're not require to use the return value, but should either save it in a variable or change treeForm() return type to void instead of int.
3) In Line 1, include the .h header file rather than the .cpp implementation file.