返回0隐式 [英] return 0 implicit

查看:105
本文介绍了返回0隐式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ACM ICPC墨西哥比赛的最后一周,我错过了一个C ++程序的返回0。因为这个原因,我们被处罚了20分钟。

The last week on the ACM ICPC Mexico competition, I missed a "return 0" on a C++ program. For this reason we got punished with 20 minutes.

我读过,标准并不强迫我们在主函数的结尾处写它。它是隐含的,不是吗?我如何证明呢?

I had read that the standard does not oblige us to write it at the end of a main function. It is implicit, isn't it? How can I prove it?

我们使用的是带有G ++编译器的Fedora系统。

We were using a Fedora system with a G++ compiler.

推荐答案

您参考C ++标准第3.6.1章第5节:

You refer to the C++ Standard, chapter 3.6.1 paragraph 5:


main中的return语句具有离开main函数
(销毁任何具有自动
存储时间的对象)和调用

效果b退出,返回值为
参数。如果控制到达结束
main没有遇到返回
语句,效果是
执行 return 0;

如果你没有手头的标准,你可以在工作草案中显示该段落。这里是一个c ++ 98,已经有这个定义。

If you haven't got the Standard at hand, you can show then the paragraph in a Working Draft. Here is one for c++98, which already had this defined.

您可以了解更多此处

这篇关于返回0隐式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆