class foo
{
public:
void set(const int a)
{b=a;}
private:
int b;
};
Here a is a constant parameter which is assigned to a non const
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Applying the const modifier to a parameter indicates that the parameter may not be changed by the function. It does not mean, though, that if the parameter’s value is assigned to another variable then that variable can’t be changed.
The purpose is to assure callers that data they pass to the method will not be changed.