안녕하세요?
C++로 코딩을 시작한지 얼마 안된 초보개발자 입니다.
문자 데이터를 사용할 때 std::string을 이용하여 대부분 처리를 하고 있는데,
함수에서 파라미터로 넘길 때 이해가 가지 않는 부분이 있어 고수분들께 여쭈어봅니다.
클래스 멤버함수로
void Manager(std::string sName, std::string sAddress);
라는 것이 있다고 가정을 하면
c++에서 파라미터 기본값 지정을 할 수 있으니
void Manager(std::string sName, std::string sAddress = "서울");
처럼 사용할 수 있겠지요?
그런데, 저 std::string에 &를 붙이면 Warning이 납니다. 정확하게 Warning이 발생하는 예를 들면
void Manager(std::string sName, std::string& sAddress = std::string("서울"))