#define或const [英] #define or const

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

问题描述

最好用于常量,#define或const标识符。并且

将const标识符放在文件中的习惯用法是什么?谢谢。

What is preferable to use for constants, #defines or const identifiers. And
where is it customary to place const indentifiers in your files? thanks.

推荐答案

Andy White写道:
Andy White wrote:
什么是常量,#define或const标识符。
习惯上将const标识符放在你的文件中?
谢谢。
What is preferable to use for constants, #defines or const identifiers.
And where is it customary to place const indentifiers in your files?
thanks.




常量。

-

如果我们的假设是关于任何事情而不是关于某一个或多个特定事物,那么我们的推论就构成了数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题.- Bertrand Russell




Andy White写道:


Andy White wrote:
对于常量,#define或const标识符,最好使用什么。并且
习惯上将const标识符放在您的文件中?谢谢。
What is preferable to use for constants, #defines or const identifiers. And
where is it customary to place const indentifiers in your files? thanks.




我会选择常数。它将在调试期间提供帮助,因为将为常量生成

符号表。但是,如果您使用#defines获得
,则在编译之前完成替换,并且不会生成
sysmbol表。此外,没有为他们执行类型检查




Soo,我建议使用常量。



I would go for constants. It would help in during debugging since the
symbol table would be generated for constants. However, if you are
using #defines then the replacement is done before compilation and no
sysmbol table gets generated. Moreover, no typechecking is performed
for them.

Soo, I would suggest for constants.




Andy White写道:


Andy White wrote:
对于常量,#define或const标识符,最好使用什么。并且
习惯上将const标识符放在您的文件中?谢谢。
What is preferable to use for constants, #defines or const identifiers. And
where is it customary to place const indentifiers in your files? thanks.




C ++建议使用常量并将它们放在标题

文件中。

http:// www-inolab。 sys.es.osaka-u.ac ...._ better_c.html



C++ recommends the usage of constants and place them on the header
file.

http://www-inolab.sys.es.osaka-u.ac...._better_c.html


这篇关于#define或const的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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