What is better practice between these two code snippets?
What's better practice between these two pieces of code? Basically, do you want to return values as much as possible, or declare 'more global' variables and have the function change the variable.
Option 1
Code:
int foo = 0;
int main() {
aFunction();
}
void aFunction() {
foo = someValue;
}
Option 2
Code:
int main() {
int foo = aFunction();
}
int aFunction() {
return someValue;
}
edit: holy macorel! just seconds after posting this, this post appeared on a google search. Google will probably take over the world.