I have a function where I pass an argument by reference since I expect the function to edit it. This function is called at several places and I only care about the ref value when called at a particular instance . Pseudocode:
test_fn(int a, int b, inc , int d, int e, int& ref)
{
//bunch of other functionalities
//.
//.
ref = (a*b+c)*(d+e);
}
test_fn(1,2,3,4,5,0)//everywhere that I do not care about ref
int value = 0;
test_fn(1,2,3,4,5, value)//I care about value here and would use it in the remainder of the code .
Why can I not pass a 0 directly ? I tried passing a NULL as well and that has a long int to an int conversion error.
Why is this wrong ? And what is the best way to achieve the expected outcome here?