+ 6
why sometimes, void is used as data type of a 'main ()' function ??
7 Answers
+ 23
every function return some value but sometimes there is no need of returning some value then void is used for void returns
+ 3
no, not now. In c++11 main can only and must return integer. What you use is not standard of c++ in its new compiler.
+ 3
@aditya K.P. it means void is never used in c++.
+ 3
A function may return or may not return a value, if a function does then the specified return type is mention in the function declaration/definition else VOID is used if the function is not returning a value.
+ 2
no, I am just saying that you can not use void or any other type unless integer for and only for main function. And you can use any type for other. In 2006, bell lab and c++ community take some decision for c++ future. It only for main() function
+ 2
The return type of main is a integer, as it is the execution status. If the main function returns 0 - all fine, something else is an error. Some compilers just can fix it by changing it while compiling, some just ignore it, like the one by Microsoft, as Windows ignores the return status as well. Integer is the correct way.
+ 1
because u will be using cout keywords in those functions and hence no return keywords.