I want to pass an IloNumArray
as an argument by reference in a function like this:
void myfuntion(...., IloNumArray & X, ...)
{
// ...
}
I know that this is not correct. Is there an other alternative?
I want to pass an IloNumArray
as an argument by reference in a function like this:
void myfuntion(...., IloNumArray & X, ...)
{
// ...
}
I know that this is not correct. Is there an other alternative?
It's considered 'wrong' to pass IloXXX objects by reference because they themselves are essentially handles pointing to the actual data, so the cost of passing the IloXXX object is the same as the cost off passing a reference. Also the semantics of copying the IloXXX objects is like passing a reference, so
void myFunction(IloNumArray x) {
x[0] = 1.0;
}
IloEnv env;
// create an array with 1 element, value of 0
IloNumArray x(env, 1, 0.0);
myFunction(x);
cout << x[0] << endl;
// 1.0