[TIL] 따배씨 수강 4일차

전재우·2022년 3월 31일
0
post-thumbnail

키워드와 식별자 이름짓기

  • 변수의 이름, 함수의 이름, 객체 이름 -> 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;
	{
		//int x = 1;
		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;  // 0
    doSomething(x);		//123
    cout << x << endl;	//0


    return 0;

}
profile
코린이

0개의 댓글