Identifying Side Effect

What is the side effect in the following function?

1
2
3
4
5
6
7
8
9
int ExamPrep (int param1, int& param2)
{
   if (param2   param1)
     return param2;
   else if (param2 > param1)
     return param1;
   else
     return param1 * param2;
}
This function won't have much of an effect at all...it won't compile due to line 3. With a name like 'ExamPrep', I'm guessing it's a homework question...

All I'll say is: consider the modes in which the parameters are passed into the function...
My apologies...I have a typo in there. It should read:

1
2
3
4
5
6
7
8
9
int ExamPrep (int param1, int& param2)
{
   if (param2 =  param1)
     return param2;
   else if (param2 > param1)
     return param1;
   else
     return param1 * param2;
}


A side effect is defined as the result of an operator, expression, statement, or function that persists even after the operator, expression, statement, or function has finished being evaluated. I don't really understand how that is presented in the above code though....
param2 is passed by reference and line 3 does not do what may look to be
http://www.cplusplus.com/doc/tutorial/functions2/
http://www.cplusplus.com/doc/tutorial/operators/
Topic archived. No new replies allowed.