mercredi 3 octobre 2018

parameter list type error in lambda function

I'm not very familiar with lambda expressions C++11. I was trying to simply invoke a method from another class taking an integer and constructing a lambda expression but I'm receiving an error about the parameter not being the correct datatype.

class A{

  int _a;
  void f(int a){
    _a = a;
  }

};

class B{

  B(){

    A instance = new A();

    instance.f(
    [&](int input)->int
    {
      int x = 2;
      return x;
     });

  };

}

Aucun commentaire:

Enregistrer un commentaire