BINDING METHOD OF MEMBER FUNCTION USING C++ AND RAMDA EXPRESSION

Asked 1 years ago, Updated 1 years ago, 35 views

Take member functions and objects as arguments for functions and capture member functions in std::bind
std::function<void()>Func=std::bind(&Foo::FooFunc,&foo);
as in
std::function<void()>Func=[&Foo::FooFunc equivalent, foo]( ) {What to do to call FooFunc}
Would it be possible to ?
Also, if possible, what kind of code would it be?

c++

2022-09-30 19:55

1 Answers

 std::function<void()>Func=[&foo]{foo->Foo::FooFunc();};

Or omit it if you don't need to specify the class name

 std::function<void()>Func=[&foo]{foo->FooFunc();};

and so on.


2022-09-30 19:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.