1. 매개변수 const
매개변수가 가르키는 곳의 데이터를 못바꾸게함
2. 함수뒤 const
이 함수내에서 맴버변수의 데이터를 못바꾸게함
3. 리턴값앞 const
나를 부른곳에서 맴버변수의 데이터를 못바꾸게함
class AAA
{
public :
void setVector(vector<int> & inputVec); //매개변수 inputvec의 내용을 바꿀수있는 함수!
void printVec() ; // 멤버변수인 name을 바꿀수있는 함수!
const string& getNameRef(); //나를 부른곳에서 name을 바꿀수있음
private:
string name;
}
class AAA
{
public :
void setVector(const std:: vector<int> & inputVec); //매개변수 inputvec의 내용을 바꾸지못함!
void printVec() const; // 멤버변수 name을 바꾸지 못함!
const string& getNameRef(); // 나를 부른곳에서 name을 바꾸지못함!
private:
string name;
}