00.02_标识符与关键字

标识符与关键字

标识符

标识符 是指用来标识某个实体的一个符号,在不同的应用环境下有不同的含义。
在计算机编程语言中,标识符是用户编程时使用的名字,用于给变量、常量、函数、语句块等命名,以建立起名称与使用之间的关系。
标识符通常由字母和数字以及其它字符构成。

特别地,标识符的第一个位置不能是数字。
例如, 是合法的, 是不合法的。

以下为各种语言的标识符介绍:

C++ : cppreference.com
Java : docs.oracle.com
Python : docs.python.org

关键字

每种语言都会有一些特殊的标识符,我们称之为“关键字”或者“保留字”。
部分关键字虽然没有实际作用,但仍然不能被用作变量名。
另外,还有一些关键字被叫做“软关键字”或者“上下文关键字”,只要不在对应语境下,也可以用作变量名(不建议这么做)。

C++

Reserved Keyword
alignas compl explicit or this
alignof concept export or_eq thread_local
and const extern private throw
and_eq consteval false protected true
asm constexpr float public try
atomic_cancel constinit for reflexpr typedef
atomic_commit const_cast friend register typeid
atomic_noexcept continue goto reinterpret_cast typename
auto contract_assert if requires union
bitand co_await inline return unsigned
bitor co_return int short using
bool co_yield long signed virtual
break decltype mutable sizeof void
case default namespace static volatile
catch delete new static_assert wchar_t
char do noexcept static_cast while
char8_t double not struct xor
char16_t dynamic_cast not_eq switch xor_eq
char32_t else nullptr synchronized
class enum operator template
identifiers with special meaning
final transaction_safe import pre trivially_relocatable_if_eligible
override transaction_safe_dynamic module post replaceable_if_eligible

Java

Reserved Keyword
abstract continue for new switch
assert default if package synchronized
boolean do goto private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
_

上面这个 _ 是下划线 。

Contextual Keyword
exports opens requires uses yield
module permits sealed var
non-sealed provides to when
open record transitive with

Python

Reserved Keyword
False await else import pass
None break except in raise
True class finally is return
and continue for lambda try
as def from nonlocal while
assert del global not with
async elif if or yield
Soft Keyword
_ case match type

上面这个 _ 是下划线 。

以下为各种语言的关键字介绍:

C++ : cppreference.com
Java : docs.oracle.com
Python : docs.python.org

牛客代码笔记-牛栋 文章被收录于专栏

汗牛充栋,学海无涯。<br/> 内含算法知识点讲解,以及牛客题库精选例题。<br/> 学习算法,从牛栋开始。

全部评论

相关推荐

叶扰云倾:进度更新,现在阿里云面完3面了,感觉3面答得还行,基本都答上了,自己熟悉的地方也说的比较细致,但感觉面试官有点心不在焉不知道是不是不想要我了,求阿里收留,我直接秒到岗当阿里孝子,学校那边的房子都退租了,下学期都不回学校,全职猛猛实习半年。这种条件还不诱人吗难道 然后现在约到了字节的一面和淘天的复活赛,外加猿辅导。华为笔试完没动静。 美团那边之前投了个base广州的,把我流程卡麻了,应该是不怎么招人,我直接简历挂了,现在进了一个正常的后端流程,还在筛选,不知道还有没有hc。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务