English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

c++ 키워드와 식별자

이 튜토리얼에서 우리는 키워드(C ++프로그래밍에서의 예약 키워드로, 그들은 문법의 일부입니다). 또한, 식별자와 그 이름 지정법에 대해 배울 것입니다.

C++ 키워드

키워드는предопределенные단어는 컴파일러에 특별한 의미를 가집니다. 예를 들어,

int money;

여기서 int는 키워드로, money가 정수형 변수임을 나타냅니다。

이것은 모든 C ++키워드 목록。(C ++ 17시작)

alignasdecltypenamespacestruct
alignofdefaultnewswitch
anddeletenoexcepttemplate
and_eqdonotthis
asmdoublenot_eqthread_local
autodynamic_castnullptrthrow
bitandelseoperatortrue
bitorenumortry
boolexplicitor_eqtypedef
breakexportprivatetypeid
caseexternprotectedtypename
catchfalsepublicunion
charfloatregisterunsigned
char16_tforreinterpret_castusing
char32_tfriendreturnvirtual
classgotoshortvoid
complifsignedvolatile
constinlinesizeofwchar_t
constexprintstaticwhile
const_castlongstatic_assertxor
continuemutablestatic_castxor_eq

주의:C ++대소문자를 구분하는 언어이므로 모든 키워드는 소문자로 작성해야 합니다。

C++ 식별자

식별자는 프로그래머가 변수, 클래스, 함수, 또는 다른 엔티티에 부여하는 독특한 이름입니다. 예를 들어,

int money;
double accountBalance;

여기서 money와 accountBalance는 식별자입니다。

식별자 이름 규칙

  • 식별자는 알파벳, 숫자, 언더스코어 문자로 구성될 수 있습니다.

  • 그것은 이름 길이에 제한이 없습니다.

  • 그것은 알파벳이나 언더스코어로 시작해야 합니다.

  • 대소문자를 구분합니다.

  • 우리는 키워드를 식별자로 사용할 수 없습니다.

위의 규칙을 따르면, 우리는 어떤 이름을 식별자로 선택할 수 있습니다. 그러나, 의미 있는 식별자를 의미 있는 이름으로 제공해야 합니다.

좋고 나쁜 식별자 예제

비법적 식별자오류 식별자좋은 식별자
총 포인트T_pointstotalPoint
1listlist_1list1
floatn_floatfloatNumber