Basicly, the main purpose of a function is to prevent repeated code, right? So, if you have a set of code that your going to use again and again, you put the code into a function, and then just call the function. My problem is with variables - how do you use a common variable in four different functions? Like if your making an rpg, you would probably need the variable Players_Health. If you have four functions that use this variable, how do you have function1 recogonize the change of the Players_Health in function2 without making a new variable each time in each function?
The only way I know to do this is to initilize and declare the variable in no function (at the very top) which is bad practice.



LinkBack URL
About LinkBacks



Have you used pointers? If not try this: