Erm...
I didn't understand about using void in functions.
I know that void doesn't return value.
but i am not clear how to use it in function.
Can anyone please show me an example how to use void in function?
Thanks in advance!
Erm...
I didn't understand about using void in functions.
I know that void doesn't return value.
but i am not clear how to use it in function.
Can anyone please show me an example how to use void in function?
Thanks in advance!
Quite simply, if you cannot return a meaningful value from a function, do not return anything. Declare its return type void (although, void is not a type). For example, a function that prints an int:
Code:// Nothing can be meaningfully retrun so, it is void... void foo(int x) { std::cout << "The int: " << x << std::endl; }
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.
thanks for reply
Some people also like to use void to explicitly indicate that a function has no parameters. So the two functions declarations below are essentially the same:
void foo();
void bar(void);
You're only born perfect.
They are the same in C++ since a prototype is a declaration. In C, however, void foo() is a declaration and void bar(void) is a prototype. A prototype is a declaration but a declaration is not a prototype.
Remember, main never returns void.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.