Which is the correct syntax of capturing a variable ‘X’ by reference and other variable ‘Y’ by value in lambda expression?

A)  [X, Y]
B)  [X, &y]
C)  [&X, Y]
D)  [&x, &Y]

Correct Answer :   [&X, Y]


Explanation : In order to capture a variable by reference we use & operator whereas when we capture a single variable by value then we just write the name of that variable without any operator preceding it, So the correct way of capturing the variables X and Y, in this case, is [&X, Y].