+ 1
difference and usages for void and integer functions?
examples of uses for Void functions? examples of uses for int functions? why my void function prints a value to the screen? I thought a void function isn't supposed to return a value. #include <iostream> using namespace std; void hope (int y) { cout<< y; } int main () { hope(89); return 0; }
2 Answers
+ 3
Printing and returning values are different processes. Printing displays to the screen while returning gives the value back to whatever called the method.
int func()
{
return 5;
}
int a = func();
a now has the value of 5 which the func() method returned.
+ 2
Thank you Jafca, that clarifies