如果我定义一个没有参数的函数,我应该放空吗? [英] if I define a function with no parameters, should i put void?

查看:93
本文介绍了如果我定义一个没有参数的函数,我应该放空吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于函数定义(不是声明/原型),如果函数不接收

参数,是否有必要将

放入emptry括号中?这是否会导致任何错误检查或导致任何其他

效果?

-thanks

For function definitions (not declarations/prototypes), is it necessary
to put void in the emptry braces if the function is to receive no
parameters? Does this turn any error checking off or cause any other
effects?
-thanks

推荐答案

TTroy写道:
对于函数定义(不是声明/原型),如果函数是不接收参数?这是否会导致任何错误检查或引起任何其他
影响?
For function definitions (not declarations/prototypes), is it necessary
to put void in the emptry braces if the function is to receive no
parameters? Does this turn any error checking off or cause any other
effects?




否。在函数_definition_ empty''()''中立即表示没有参数。


-

祝你好运,

Andrey Tarasevich



No. In a function _definition_ empty ''()'' immediately means "no parameters".

--
Best regards,
Andrey Tarasevich

Andrey Tarasevich写道:
Andrey Tarasevich wrote:
TTroy写道:
TTroy wrote:
对于函数定义(不是声明/原型),是否有必要放置
如果函数是不接收
参数,则在emptry括号中为void?这是否会导致任何错误检查或导致任何其他
影响?
For function definitions (not declarations/prototypes), is it necessary
to put void in the emptry braces if the function is to receive no
parameters? Does this turn any error checking off or cause any other
effects?



否。在函数_definition_ empty''()''中立即表示无参数。


No. In a function _definition_ empty ''()'' immediately means "no parameters".




< Style Opinion>

我个人认为放置void在parens里面

使代码更具可读性。但这是我的意见。

< / Style Opinion>


-

Thomas Matthews


C ++新闻组欢迎信息:
http: //www.slack.net/~shiva/welcome.txt

C ++常见问题: http://www.parashift.com/c++-faq-lite

C常见问题: http://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn.c-c ++ faq:
http://www.comeaucomputing.com/learn/faq/

其他网站:
http://www.josuttis.com - C ++ STL图书馆书籍
http://www.sgi.com/tech/ stl - 标准模板库



<Style Opinion>
I personally believe that placing "void" inside the parens
makes the code more readable. But that is my opinion.
</Style Opinion>

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library




Andrey Tarasevich写道:

Andrey Tarasevich wrote:
TTroy写道:
对于函数定义(不是声明/原型),如果函数不接收
参数,是否需要将
放入emptry括号中?这是否会导致任何错误检查错误或导致任何
其他影响?
否。在函数中_definition_ empty''()''立即表示否
For function definitions (not declarations/prototypes), is it necessary to put void in the emptry braces if the function is to receive no
parameters? Does this turn any error checking off or cause any other effects?
No. In a function _definition_ empty ''()'' immediately means "no



参数"。


parameters".




即使我使用函数的empty()定义作为唯一的

声明?


我还有另外一个问题。如果我正在调用一个函数并且还要使用b
投射参数的值,那么这个演员是否会在原型引起的自动转换之前或之后出现?我猜这个问题

适用于没有原型的情况 - 这种情况发生在促销之后或者

之后?



Even if I use the empty () definition of a function as the only
declaration?

I also have another question. If I was calling a function and also
casting values of arguments, does this cast come BEFORE or AFTER the
automatic conversion caused by the prototype? I guess the question
applies when there is no prototype - does the case happen before or
after the promotions?


这篇关于如果我定义一个没有参数的函数,我应该放空吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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