C++ void return type of main()

后端 未结 8 2448
灰色年华
灰色年华 2020-12-11 01:58

Some C++ compilers allow the main function to have return type void. But doesn\'t the Operating System require int type value returned to specify

8条回答
  •  醉酒成梦
    2020-12-11 02:14

    main returning void is accepted for backwards compatibility, but it is not legal.

    In this case, the exit code will be 0. You can still change the exit code, using exit function.

提交回复
热议问题