목록첨자 연산자 (1)
일상 코딩
[C++/9.06] 첨자"[]" 연산자 오버로딩
#include #include class IntList { private: int m_list[10]{1,2,3,4,5,6,7,8,9,10}; public: // void setItem(int index, int value) // { // m_list[index] = value; // } // int getItem(int index) // { // return m_list[index]; // } // // array 자체를 포인터로 얻는 방법 // int * getList() // { // return m_list; // } int & operator [] (const int index) { // 이렇게 assert로 막아줘야 // runtime error debugging시 시간을 // 아낄 수 있다..
C++/따배C++ 09강 연산자 오버로딩
2021. 10. 30. 01:18