Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it bad to type void main() in C++ [duplicate]

Tags:

c++

standards

Possible Duplicate:
Difference between void main and int main?

Why is

void main() {
    //return void
}

bad?

The other day I typed this and someone pointed out to me that it is wrong to do so. I was so confused. I have been writing like this for a while now, I know it isn't C++ standard, but the compiler doesn't give out any warnings. Why is this wrong?

like image 369
Eve Avatar asked Dec 09 '22 01:12

Eve


2 Answers

Because the compiler you use does not error out on it, it doesn't mean other compilers won't. You know its not standard, after all...

like image 164
K-ballo Avatar answered Dec 23 '22 14:12

K-ballo


It is wrong exactly because it is not standard. One compiler might accept this, another might complain, and the pedantic believers will burn your ass on the stake anyways.

like image 33
Xeo Avatar answered Dec 23 '22 16:12

Xeo