프로그래밍/C++

범위지정 연산자 (Scope Resolution Operator)

DevIt 2013. 7. 20. 04:12

범위지정 연산자 (Scope Resolution Operator) 사용 예제


#include <iostream>

using namespace std;


int value=100; //전역변수


void test(void)

{

int value=200; //지역변수

value+=100;

cout << "지역변수 value : " << value << endl;

::value+=100; //범위지정 연산자 (Scope Resolution Operator) :: 사용

cout << "전역변수 value : " << ::value << endl;


}


int main(void)

{

test();

return 0;


Scope 연산자를 이용하여 전역변수에 접근하는 예제입니다.