class Something()
{
public:
int m_value;
Something(const Something& st_in) // 복사 constructor
{
m_value = st_in.m_value;
}
void setValue(int value){ m_value = value;}
//int getValue() { return m_value; }
int getValue() const // 확실하게 const라고 명시해주어야 함.
{
return m_value;
}
}
void print(const Something &st) // const와 &로 주소를 효율적으로 쓸 수 있다.
{
cout << &st << "\n";
cout << st.getValue() << "\n";
}
int main()
{
const Something something;
// something.setValue(3); -> const이므로 값 바꾸는 것은 불가능
cout << something.getValue() << "\n"; int getValue()로만 쓰여있으면 불러오는 것도 불가능.
return 0;
}