목록비교 연산자 오버로딩 (1)
일상 코딩
[C++/9.04] 비교 연산자 오버로딩
※ 비교 연산자 오버로딩시 주의점. return 문 안에서 오름차순은 ""으로 #include #include #include #include using namespace std; class Cents { private: int m_cents; public: Cents(int cents = 0) { m_cents = cents; } int getCents() const { return m_cents; } int &getCents() { return m_cents; } friend bool operator < (const Cents &c1, const Cents &c2) { return c1.m_cents < c2.m_cents; } friend std::ostream &operator
C++/따배C++ 09강 연산자 오버로딩
2021. 10. 29. 01:08