Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- algorithm
- 홍정모님
- 단항연산자
- coursera
- sizeof()
- 코딩테스트
- Andrew Ng
- #define
- C++
- classification problem
- 이코테
- compile time constants
- 나동빈님
- CLion
- decimal
- #endif
- const
- 코드블럭 오류
- 본즈앤올
- 학습 알고리즘
- standford University
- 형변환
- regression problem
- 기계학습
- Machine Learning
- 기계학습 기초
- Greedy
- 프로그래밍
- 연산자
- Runtime constants
Archives
- Today
- Total
wellcome_공부일기
01.05. C++ | 함수 및 변수 이름 짓는 규칙, 키워드와 식별자 차이 본문
<목차>
1. 키워드(Keywords)
2. 식별자(Identifiers)
3. 함수 및 변수 이름 짓는 규칙
키워드(Keysords)란?
프로그래밍 상에서 하나의 단어로서 자리잡은 것으로, 키워드(Keywords)로 함수 및 변수 이름을 지어서는 안됩니다.
(이미 프로그램 상에서 사용하고 있다고 생각하면 쉽습니다.You cannot use it as variable name, constant name etc.)
C++의 키워드는 아래 표에서 확인할 수 있습니다.

식별자(Identifiers)란?
식별자란 C++에서 변수, 객체, 클래스, 함수 등의 이름입니다.
앞서 말했듯 이미 프로그램 상에서 고유 단어로 사용된 키워드를 식별자로 다시 지정할 수 없습니다.
함수 및 변수 이름 짓는 규칙
그 외에도 식별자를 만들 때는 규칙이 있습니다.
1. 식별자는 문자와 _(underscore) 혹은 $(dollar sign)으로 시작해야만 한다. (숫자로 시작해서는 안된다.)
2. 식별자는 영숫자 문자와 _(underscore) 혹은 $(dollar sign)로 이루어져야 한다.
ex ) Good : firstName, sum, vector1, last_name
Bad : 12th_digit, half-way, %interest
3. 또한 C++에서는 대문자와 소문자를 구분한다.
ex ) number1 ≠ Number1
4. 보통 함수 명은 " 명사 " 혹은 " 동사+명사 " 순으로 이름을 짓는 것이 대중적이다.
#include <iostream>
using namespace std;
//4.번 예
void runApple()
{
cout << "Apple" << endl;
}
//3.번 예
void Jobs()
{
runApple();
}
void jobs()
{
cout << "Study Apple" << endl;
}
int main()
{
//1,2번 예
int $_1 = 1;
int _$ = 2;
cout << $_1 << endl; // output : 1
cout << _$ << endl; // output : 2
Jobs(); // output : Apple
jobs(); //output : Study Apple
return 0;
}
'프로그래밍 > C++' 카테고리의 다른 글
01.07. C++ | 피연산자(Operand) 갯수에 따른 연산자(Operator)의 3가지 종류 (0) | 2020.04.24 |
---|---|
01.06. C++ | 식별자의 범위(Scope of an Identifier) (0) | 2020.04.23 |
01.04. C++ | 함수의 구조, 인자와 인수 차이점 (0) | 2020.04.21 |
01.03. C++ | 입출력 살펴보기 (0) | 2020.04.20 |
01.02. C++ | 객체와 변수란? (0) | 2020.04.19 |
Comments