C++ 참조
참조 생성
참조 변수는 기존 변수에 대한 "참조"이며 다음 &
연산자로 생성됩니다.
string food = "Pizza"; // food variable
string &meal = food;
// reference to food
이제 변수 이름 food
이나 참조 이름 meal
을 사용하여 food
변수를 참조할 수 있습니다.
예시
string food = "Pizza";
string &meal = food;
cout << food << "\n";
// Outputs Pizza
cout << meal << "\n"; //
Outputs Pizza