保留字和关键字的区别?
C++ 中的保留字和关键字有什么区别?
“main”是保留字还是关键字?
What are the differences between reserved words and keywords in C++?
Is 'main' a reserved word or a keyword?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能想到的唯一可能区分两者的事情是,是否保留一个单词以供将来使用(即不是关键字,但也不允许使用)。但是,我想不出一个例子...
Main 本身不是关键字,但 C、C++、C# 和类似语言通常需要它作为应用程序的开始执行点。这些语言各自在相应的语言规范中定义了 main 的角色。
The only thing I could think of that might differentiate the two is if a word was reserved for future use (i.e. not a keyword, but also not allowed for use). However, I couldn't think of an exapmle off the top of my head...
Main is not a keyword per se, but it is usually required by C, C++, C#, and similar languages as the beginning execution point of your app. These langauges each define the role of main in the corresponding language specification.
直观上,我认为关键字必须有意义。有些语言具有实际上不是关键字的保留字。 (例如,Java 保留了 goto,即使它没有 goto 语句。)
而 main 只是一个经过特殊处理的函数名称。
Intuitively, I'd say a keyword has to have a meaning. Some languages have reserved words that are not actually keywords. (Java reserves goto, even though it does not have a goto statement, for example.)
And main is just a function name that is treated specially.