mardi 8 octobre 2019

how to pass local variable and argument of same name inside lambda functions in c++?

#include <iostream>
int main(){
    int a = 10; 
    function<int(int)> functionPointer = [a](int a)-> int{ return a + a + 100 ; };
    int returnValue = functionPointer(50);
    std::cout<<returnValue<<endl;
}

I want answer as 10+50+100 = 160 but it gives 10+10+100 = 120

**how can i get answer 160? **

Aucun commentaire:

Enregistrer un commentaire