until there I trusted that method like
bool solverMethod::buildSimplex(double** simplex_ , double* funcEvals_, double* initPt_)
{
// things
}
would change values for simplex, funcEvals_, initPt_ in the method where it is called (passage by pointer). Am I wrong? How to put it then?
thanks and regards and apologizes for simple question.
This is maybe not as much an answer as it is a general explanation of pointers, references and reference semantics.
A function is said to have reference semantics if it can change the argument objects that are passed to it. For example, the following
swapfunction has reference semantics if it exchanges the values:The question is how you implement reference semantics. C++ has a native reference type that makes this very natural:
By contrast, C does not have such a native feature, and every object in C is passed by value. However, C has a different feature that can be used to implement reference semantics, namely pointers: For every type
T, there is a related typeT*, a value of which can be obtained by taking the address-of an object of typeT:int x; int * p = &x;. Now you can pass those pointer objects around by value and use them to access the original object to which they point. Notice that we are passing the pointers by value!We have to call the function differently:
swap(&x, &y). Thus in C you can always tell whether an argument is being modified, because the only way to do this is by passing its address to a function. In C++, you have to know the actual function signature to know whether reference or value semantics are in place.