i\'m trying to understand a concept and an error. what\'s wrong with this?
class A
{
public:
A()
{
std::function testFunc(&a
my question, is it possible to create any sort of object that is able to call a member of a specific instance
In this case the only information that is missing is in fact what specific instance the std::function
object should use: &A::func
can't be used on its own (for instance (this->*&A::func)(0)
uses &A::func
with instance *this
). Try:
std::function testFunc = std::bind(&A::func, this);
(Be careful that std::bind(&A::func, *this)
and std::bind(&A::func, this)
have slightly different semantics.)