重新定义C ++关键字是否合法? [英] Is it legal to redefine a C++ keyword?
本文介绍了重新定义C ++关键字是否合法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在来自Guru的这篇文章中,有人说:这是非法的#define一个保留字。
这是真的吗?
In this article from Guru of the week, it is said: It is illegal to #define a reserved word.
Is this true? I can’t find anything in the norm, and I have already seen programmers redefining new, for instance.
推荐答案
17.4.3.1.1宏名称[lib.macro.names]
1在标题中定义为每个名称如果翻译单元包括头部,则保留给任何使用。)
2包含头部的翻译单元不应包含定义在该头部中声明或定义的名称的任何宏。 此类翻译单元也不应为与关键字在词汇上相同的名称定义宏。
顺便说一句, code> new 是一个运算符,用户可以通过提供自己的版本来重载(替换)。
By the way, new
is an operator and it can be overloaded (replaced) by the user by providing its own version.
这篇关于重新定义C ++关键字是否合法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文