cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
return in function
return in function
Dec 1, 2012 at 8:08pm UTC
Donanza
(129)
When do you not have to use the keyword return when you define a function???
Dec 1, 2012 at 8:12pm UTC
Athar
(4466)
When it doesn't return anything (void).
Dec 1, 2012 at 8:24pm UTC
Donanza
(129)
lol, thanks :)
Dec 1, 2012 at 9:28pm UTC
andywestken
(4087)
And in
int
main()
If you omit it, it assumes you meant return 0;
1
2
3
4
5
6
7
#include <iostream>
using
namespace
std;
int
main() { cout <<
"Hi!\n"
; }
Last edited on
Dec 1, 2012 at 9:29pm UTC
Dec 1, 2012 at 9:40pm UTC
Chervil
(7320)
And in the contrary situation, even when the return type is void, the keyword return may still be used. It's particularly useful to terminate processing before reaching the closing brace of the function.
Topic archived. No new replies allowed.