c++ - pass by reference : no known conversion for argument 6 from 'int' to 'int&' -
i have function pass argument reference since expect function edit it. function called @ several places , care ref value when called @ 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 not care ref int value = 0; test_fn(1,2,3,4,5, value)//i care value here , use in remainder of code .
why can not pass 0 directly ? tried passing null , has long int int conversion error.
why wrong ? , best way achieve expected outcome here?
in order pass variable reference has exist, passing 0 or null
means you're sending in constant. cannot edit value of constant, actualy not variable.
as solving problem, probaby should use pointers achieve that, check if pointer set 0, null
or if use c++11, nullptr
Comments
Post a Comment