Please note that pointers are used instead of references: ...
int main(){
std::vector<int> testData{100,500,60};
auto atValue = [=](std::vector<int> &vec,int *data){
for(auto it = vec.begin();it != vec.end();it++){
if (*it == 500) {
data = &*it;
break;
}
}
};
int *tint = NULL;
atValue(testData,tint);
//*tint = 50;
printf("%d",*tint);
return 0;
}
felix said:
int data changed to int &data
The problem has been solved.Thank you.
have try