0
Whats wrong in ref argument
Hi We can pass local variable to capture clause of lambda as reference. With this, local variable can be modified from lambda body. It is working fine for me in code below: Question is related to functor. I am trying to achieve same thing with functor class having int& as reference member. Wha's the issue here as I am not getting i modified from functor. https://code.sololearn.com/cmntGs1Rrp5m/?ref=app
3 odpowiedzi
+ 3
Ketan Lalcheta pass by reference in the class constructor.
class myFunctor
{
int& i;
public: This⤵️
myFunctor(int& i) : i(i) {}
void operator()() {++i;}
};
https://code.sololearn.com/cb9DAcV0IwYT/?ref=app
+ 1
very good YouTube tutorial on functor usage
https://youtu.be/qcuYSqHxqLk
+ 1
Thanks for sharing this video... Learnt something new now about use case of functor with template