I have a problem that similar to : this question
But I still don’t understand what is the difference between :
void test(TestInfo&)
{
}
and
void test(const TestInfo&)
{
}
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.
The first passes a reference while the second passes an
constreference to the functiontest(),Note that
constreference basically means a reference to aconstdata.In the second case you cannot modify the contents of
TestInfoinside the function.Any attempt to modify the passed
TestInfoobject inside the function would result in aUndefined Behavior.