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?”

### Leave a Comment

You must be logged in to post a comment.

a) [&X, Y]

b) [X, &y]

c) [X, Y]

d) [&x, &Y]

You must be logged in to post a comment.

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