void means "don't return value" right? but wat does don't return value different from the normal ones.
void means "don't return value" right? but wat does don't return value different from the normal ones.
S.b
pretend that the type of the function, i.e. the type presented before the function:
is what is going to be replaced where the function was called.Code:int blah()
Example:
the blue is the function being called and the type is intCode:int add() { return 1+1 ; } int main() { int j=0; j=add(); return 0; }
in main, WHERE it is called (red) you can pretend that you can replace that location with what it returns. (1+1, or just flip the reds)
however, with void...
in the void add() function.. it doesn't return anything so, in the main, you can't replace the location where you called it with anything (the red).Code:void add() { return ; } int main() { add(); return 0; }
I am sorry if this is unclear. I tried to explain it as simply as I could
-LC
Asking the right question is sometimes more important than knowing the answer.
Please read the FAQ
C Reference Card (A MUST!)
Pointers and Memory
The Essentials
CString lib
You can use a void function for a lot of things. Say u wanted a function to just out put some information
Code:void output() { cout << "HEllo"<<endl; } int main() { output(); return 0; }
C++ Rules!!!!
------------
Microsoft Visual Studio .NET Enterprise
If there is no meaningful value that your function could return, then it shouldn't return anything, and consequently, have a void return type.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
just like void main() !Originally posted by Zach L.
If there is no meaningful value that your function could return, then it shouldn't return anything, and consequently, have a void return type.
just kidding
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
i still not understand by "return a value".Whether void or not,u will still get the value of the whole nest thing
S.b
Well I'll am not very sure but what I understand by return values is this: when you make a function, the compiler leaves space in the stack for the return value, that can be an int, a bool, a double or anything like that, but when you make a void function, it leaves no space for the return value. You may want to google what the stack is, then it will be much clear, I dont know how to explain it... sorry.
Why drink and drive when you can smoke and fly?