0

Can anyone help me with what is different between int main() and int main(void)?

Biffen
  • 6,249
  • 6
  • 28
  • 36
Alvi Lika
  • 9
  • 4

2 Answers2

2

Using (void) as the single parameter in a C++ function is exactly equivalent to using ().

Although, stylistically (void) is to be discouraged.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
0

In C++, there is no difference. The difference only arises in C, where not explicitly mentioning void in the parameter list allows the function to be called with any number of parameters, while the second version only allows exactly 0 parameters.

R_Kapp
  • 2,818
  • 1
  • 18
  • 32