Programming/C++
-
[c/c++] call-by-value와 call-by-referenceProgramming/C++ 2019. 1. 8. 19:42
*열혈C 프로그래밍 강의를 듣고 정리한 내용입니다. 잘못된 정보나 오타가 있을시 피드백 부탁드립니다.* - 들어가기전 함수에게 인자를 전달하는 형태는 여러가지가 있습니다. C에서는 call-by-value와 call-by-reference가 가장 많이 쓰이는 형태이며 함수의 인자로 전달되는 대상에 따라 함수의 호출 방식이 구분되어집니다. 단순히 값을 인자로 전달하는 경우를 '값에 의한 호출' 즉, call-by-value라 하고 메모리 접근에 사용되는 주소값을 인자로 전달하는 경우를 '참조에 의한 호출' 즉, call-by-reference라 합니다. Call-by-value (값에 의한 호출) : 변수(메모리 공간에 저장된 값)의 값을 복사하여 함수의 인자로 전달하는 방식#include using na..