是否c + +允许默认返回类型的功能呢? [英] Does C++ allow default return types for functions?

查看:54
本文介绍了是否c + +允许默认返回类型的功能呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C以下的恐怖是有效的:

In C the following horror is valid:

myFunc()
{
  return 42;  // return type defaults to int.
}

但是,这个在C ++?我找不到它的一个引用无论哪种方式...

But, what about in C++? I can't find a reference to it either way...

我的编译器(codegear C ++ Builder的2007年),目前接受它没有任何警告,但我有意见,这 C中的错误++。

My compiler (Codegear C++Builder 2007) currently accepts it without warning, but I've had comments that this is an error in C++.

推荐答案

这是病态的的C ++中。这意味着它不会与一个符合标准的编译器来编译。第 7.1.5 / 4 本标准的附录C解释了改变禁止隐式int类型。

It's ill-formed in C++. Meaning that it doesn't compile with a standard conforming compiler. Paragraph 7.1.5/4 in Annex C of the Standard explains the change "Banning implicit int".

这篇关于是否c + +允许默认返回类型的功能呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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