Technote/Data Structure C++ [C++] 레퍼런스를 이용한 Call-By-Reference Pooh0216 2009. 9. 16. 23:13 #include using std::cout; using std::endl; void swap(int &a,int &b) { int temp = a; a= b; b = temp; } int main(void) { int val1 = 10; int val2 = 20; cout << "val1:"< swap 함수 내에서는 a와 b 라는 이름으로 main 함수 내에 선언된 변수 val1 과 val2 에 직접 접근이 가능하게 된다. 저작자표시 (새창열림)