목록반환값 최적화 (1)
배움 저장소
[홍정모의 따라하며 배우는 C++] 9.연산자 오버로딩
9.1 산술 연산자 오버로딩 하기 add 함수를 구현해보자. Parameter가 늘어날 때마다 오버로딩을 해주어야 한다 class Cents { private: int m_cents; public: Cents(int cents=0){ m_cents = cents; } int getCents() const { return m_cents; } }; Cents add(const Cents& c1, const Cents& c2){ return Cents(c1.getCents() + c2.getCents()); } int main(){ Cents wallet1(5); Cents wallet2(13); cout
Programming Language/C++
2021. 12. 25. 20:15