NEED HELP with my Function !!!,
Members - Reputation: 122
Posted 08 August 2001 - 06:52 AM
Members - Reputation: 2210
Posted 08 August 2001 - 07:11 AM
Right.... the problem is that the variables that you pass to process_deposits are being copied. You are incrementing the copies, and then as soon as the function exits the incremented values are thrown away. There are several solutions to this problem....
1. Use a return value from process_deposits to give you the new value. Problem: you can only return one piece of data, so all the other things will still be lost.
2. Make all the things you want to change in process_deposits global. Problem: heavy use of globals is evil. (although for a simple app like this it is fine)
3. Pass the data that needs to be changed to the function using pointers. Problem: if you dont know what you are doing with pointers you will probably get lots of nasty crashes and errors and stuff.
4. Pass the data by reference. Problem: Only works in C++, but since you are using C++, that shouldnt be a problem. This is probably the best solution. Change your definition of process_deposits to this...
Edited by - Sandman on August 8, 2001 2:16:30 PM