안녕하세요.
현재 Effective c++로 공부중에 있습니다.
const 관련부를 공부하다가 비상수 객체를 상수 객체로 변경하는 부분인데요.
클래스명은 CMyString 입니다.
하나의 함수는 const char& operator[](int nIndex) const 이구요.
하나의 함수는 char& operator[](int nIndex) 입니다.
char& operator[](int nIndex) 함수 내에서
const char& operator[](int nIndex) const 함수를 호출하기 위해서
객체를 형변환 해주는데요.
그 부분이 (static_cast<const CMyString&>(*this))[0]; 입니다.
여기서 제가 궁금한 점은
형을 꼭 <const CMyString&>으로해줘야 하는 것인지 입니다.