C ++中的标识符不能是关键字,可以吗? [英] Identifier in C++ cannot be a keyword, can it?

查看:82
本文介绍了C ++中的标识符不能是关键字,可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下关键字来描述我的当下心情:

此新的受私人保护的案例,供公众尝试抛出长错误的带符号的并集或不由朋友删除双自动类,并使用真正的虚拟volatile返回短暂的静态中断,而如果注册捕获否则浮动则默认导出 >

这些关键字标识符是吗?我的问题是我可以将它们与重新定义或重载一起使用吗?不,为什么不呢?不能用于程序员创建的标识符的标准保留关键字是:..."-对不起?!这是什么意思?我不明白他们为什么给我一些关键字,并告诉我不要使用它们.那我应该使用什么标识符?

感谢您的回答!

解决方案

这些关键字标识符是吗?

否,关键字不是标识符.

他们给了我一些关键字,并告诉我不要使用它们.那我应该使用什么标识符?

对于标识符,您必须使用不是关键字的任意单词.

使用示例更容易解释.
考虑这一行:

  int foo = 42; 

在这里, int 是一个关键字.这行使 foo 成为标识符.
但是,此行:

  int朋友= 42; 

格式错误(即无法编译),因为它会尝试将关键字( friend )用作标识符.

I can describe my moment mood with the following keywords:

this new private protected case for public try throw long false signed union or not friend delete double auto class and return short static break using true virtual volatile while do default export if register catch else float

Are these keywords identifiers? My question is can I use these with re-definition or overloading? No. But why not? "The standard reserved keywords that cannot be used for programmer created identifiers are: ..." - Excuse me?! What does it means? I can't understand why they gave me some keywords and tell me not to use them. What identifiers should I use then?

Thanks for the answering!

解决方案

Are these keywords identifiers?

No, keywords are not identifiers.

they gave me some keywords and tell me not to use them. What identifiers should I use then?

For identifiers you have to use arbitrary words that are not keywords.

It's easier to explain with an example.
Consider this line:

int foo = 42;

Here, int is a keyword. This line makes foo an identifier.
However, this line:

int friend = 42;

would be ill-formed (i.e. wouldn't compile), as it tries to make a keyword (friend) an identifier.

这篇关于C ++中的标识符不能是关键字,可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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