목록클래스 (1)
일상 코딩
[C++/8.2] 캡슐화, 접근 지정자, 접근함수
#include #include #include using namespace std; class Date { // 기본이 private으로 설정되어있음. 안적어도 무방함. private: // access specifier int m_month; int m_day; int m_year; public: void setDate(const int& day_input, const int& year_input) { m_day = day_input; m_year = year_input; } void setMonth(const int& month_input) { m_month = month_input; } const int& getDay() // const로 수정을 막아준다. { return m_day; } void..
C++/따배C++ 08강 객체지향 기초
2021. 10. 20. 03:14