1

This example is from MQL4 but that doesn't really matter:

int OnCalculate( const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] ) 

What does matter is that I don't understand what the bitwise operator & is telling me here.

I know what happens if you have 2 variables and use it var1 && var2 but in this situation with an array, could someone help me out here?

1

1 Answer 1

1

The &in the argument indicates pass-by reference and not bitwise and. Passing by reference as opposed to pass-by value means that the argument value isn't copied, instead it's the address to the data structure that is copied and passed in to the function.

Edit: see @Sneftel's comment below about pass-by reference

Sign up to request clarification or add additional context in comments.

2 Comments

Nitpick: The & does not technically indicate pass-by-reference (there's no such thing in the language), but that the variable being passed is a reference. The difference can be seen in the fact that the variable type inside the function is treated as a reference type, not as a non-reference type.
@Sneftel Good catch, I'll edit the answer and point to your comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.