C++:标识符、关键字、名称和实体之间有什么区别?
下面的“identifier”是变量i
的名称吗? int
是“关键字”吗?
int main()
{
int i;
}
我无法理解关键字、标识符、名称、实体之间的区别。
In the following, is "identifier" a name of a variable i
? Is int
a "keyword"?
int main()
{
int i;
}
I'm not being able to understand the difference between a keyword, identifier, name, entity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于变量
int i
,int
是类型,i
是名称。对于变量本身,i
将是标识符;然而,int
是类型的标识符。类型可能是但并不总是关键字。标识符指的是某个对象、类型等。名称指的是对象的实例。实体指任何类型的对象,包括基本类型(int、char 等)。
For the variable
int i
,int
is the type andi
the name. For the variable itself,i
would be the identifier; however,int
is the identifier for the type.Types may be, but are not always, keywords. Identifiers refer to a certain object, type, etc. Names refer to an instance of an object. Entities refer to any sort of object, including basic types (int, char, etc).
i
这里是一个标识符。int
是一个type
,实际上是一种数据类型。标识符:
MSDN 中的定义:
标识符是用于表示以下内容之一的字符序列:
关键字:
C++ 保留一组 63 个单词供自己使用。这些单词称为关键字,每个关键字在 C++ 语言中都有特殊的含义。
此处查看关键字列表。
好读:
什么是标识符?
什么是关键字?
i
is an identifier here.int
is atype
, actually a data type.Identifiers:
Definition from MSDN:
An identifier is a sequence of characters used to denote one of the following:
Keywords:
C++ reserves a set of 63 words for it’s own use. These words are called keywords, and each of these keywords has a special meaning with in the C++ language.
Check out the list of keywords here.
Good Read:
What are identifiers?
What are keywords?