키워드와 식별자 이름짓기
- 변수의 이름, 함수의 이름, 객체 이름 -> Identyfy
- 프로그램의 주소를 프로그래머가 인식할 수 있는 이름으로 변환해준다라고 생각.
int total; 가능
int _orange; 가능
int VALUE; 가능
int my variable name; 불가능
int TotalCustomers; 가능
int void; 불가능 (예약어)
int numFruit; 가능
int 2some; 불가능 (숫자첫글자 x)
int meters_of_pipe; 가능
지역범위
#include <iostream>
using namespace std;
int main()
{
int x = 0;
cout << x << " " << &x << endl;
{
x = 1;
cout << x << " " << &x << endl;
}
{
int x = 2;
cout << x << " " << &x << endl;
}
}
#include <iostream>
using namespace std;
void doSomething(int x)
{
x = 123;
cout << x << endl;
}
int main()
{
int x = 0;
cout << x << endl;
doSomething(x);
cout << x << endl;
return 0;
}