const, non-const, getter를 복제하는 우아한 솔루션? [복제] 이 질문에는 이미 답변이 있습니다. 비슷한 const 함수와 non-const 멤버 함수 사이의 코드 복제를 어떻게 제거합니까? 답변 17 개 당신이 그것을 할 때 그것을 싫어하지 마십시오 class Foobar { public: Something& getSomething(int index) { // big, non-trivial chunk of code... return something; } const Something& getSomething(int index) const { // big, non-trivial chunk of code... return something; } } const버전에서 비 버전을 호출 할 수..