![]() |
|
#1
|
|||
|
|||
void& binar treeshi guys
i need to build a binar tree from a file. i have a function that i must use (Void initInventory(char *invFileName, double bal, chemTree *invTree) the problem is whem i finish to build the tree and return to the menu the tree is empty again. when i change the function to chemTree* initInventory( char *invFileName, double bal, chemTree *invTree) then it work , but its not allowed thanks |
|||
|
#2
|
|||
|
|||
Re: void& binar treesQuote:
Quote:
Quote:
If it is not allowed, then don't do it. Bottom line: It is my opinion that there is no way (that's no way) that someone can help you understand how to fix your code without seeing some code. In other words: Show us some code. But I already said that. Regards, Dave |
|
#3
|
|||
|
|||
Re: void& binar treesCPP / C++ / C Code:
thanks mate Last edited by admin : 12-Jul-2009 at 04:21.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|
#4
|
|||
|
|||
Re: void& binar treesQuote:
Noit really I hate to repeat myself but when you said you "have a function" that you must use, I asked: Quote:
Then I said Quote:
Now, as far as the nature of the problem: If you feed a pointer to a function, the function can not (that's not) affect the value of the pointer back in the calling function. It can affect whatever the pointer is pointing to. Therefore, if you are not allowed to return some new value of pointer, then you have to do something else: Either 1. You can pass the function a pointer to the pointer, and then have the function change the pointer. But when you say that you "have a function" that you must use, does that mean you can't change the function prototype or what? or 2. Another way might to make the pointer point to an "empty" node (representing the root of the tree) before calling the function. Then the function might add nodes or some such thing by linking to the root node. The pointer will still be pointing to the root, but the root itself has been changed. Since we don't know what your assignment is and I am having a hard time trying to guess, what you have in mind, well... Regards, Dave |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Recommended reading for trees | hira | C Programming Language | 1 | 05-Nov-2008 11:28 |
| Implementing id3 algorithm/decision trees | spyrax | Miscellaneous Programming Forum | 0 | 30-Oct-2007 23:05 |
| Trees | ajohn | C Programming Language | 2 | 14-Nov-2006 13:40 |
| Trees and Keys (not for the faint-hearted!) | greymalkin | C++ Forum | 11 | 08-Nov-2005 09:04 |
| folder problem in trees | zuzupus | MySQL / PHP Forum | 23 | 26-Sep-2003 08:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The