Understanding void
| ftmthy412 (3) | |||
| Hi I'm very new to C++. I'm teaching myself from online tutorials with minimal previous programming experience. I have a question about void. I read that declaring a function void means that that function does not return a value. How can a function not return any value and still contribute to the program? Do I not correctly understand the way the definition uses the term "return"? Thanks. | |||
| yang (28) | |||
| a fuction is not contribute to a program just by return a value, the main funtion always return 0, this is not all of its contributions. | |||
| psault (80) | |||
a void function can still perform actions, and there is a way using what are called "references" to get it to pass back modified variable values even though it has no return value as a function.
this lets main() get a return value for the variable z using a reference (the & symbol), in this case the number 5. | |||
This topic is archived - New replies not allowed.
