c ++标准禁止void main()原型吗? [英] does c++ standard prohibit the void main() prototype?
问题描述
在C ++ Standard 1998和2003版本的3.6.1.2节中,
实现不应预定义主函数。此功能不应重载。它应该
返回类型类型int,否则其类型是实现定义。
母语为英语的人。我不确定否则是什么意思。是否禁止其他返回类型,或赋予C ++编译器作者权利?
您所引用的英文禁止声明
主 c>返回 void
。它允许变量的参数,但不是在返回类型。
In section 3.6.1.2 of both C++ Standard 1998 and 2003 editions,
An implementation shall not predefine the main function. This function shall not be overloaded. It shall
have a return type of type int, but otherwise its type is implementation-defined.
I am not a native English speaker.I do not sure what does"but otherwise" means.Whether it is to prohibit the other return type,or to give the right to C++ compiler writer?
So what's the answer?
解决方案 The english you quote does prohibit declaring main
to return void
. It is allowing variation in the arguments that come in, but not in the return type.
这篇关于c ++标准禁止void main()原型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!