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]

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

  1. a
    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].

Leave a Comment