0
Can we declare main as void and not use return statement
6 Answers
+ 2
C++ does not support void Main(). If you want to use void just use like this.
public int Main()
{
main_void();
return 0;
}
public void main_void()
{
// here goes the code
}
+ 1
"The definition void main() is not and never has been used in C++."
by creator of c++
when you use void main instead of int. It will throw an error. that main should be int.
+ 1
You can omit the "return 0;" inside the main function, but it needs to be int.
+ 1
In my experience, you can use void and it will still operate correctly. But, using int gives you an advantage; you can use return 0 to terminate the program whenever you want.
0
lets assume void main() works in c but not in c++.
0
no because void main is start of program