#include <iostream>
#include <functional>
using namespace std;
class Temp {
public:
typedef function<void(int)> callback;
void setcallback(callback cb)
{
cb_ = std::move(cb);
}
void cb(int j)
{
cb_(j);
}
callback cb_;
};
class Test
{
public:
Test(int i) :i_(i), tmp(new Temp())
{
tmp->setcallback(bind(&Test::show, this, placeholders::_1));
};
void show(int j)
{
cout << i_ << endl;
cout << "hahaha" << endl;
cout << j << endl;
}
Temp* tmp;
int i_;
};
int main()
{
Test* p = new Test(5);
p->tmp->cb(6);
return 0;
}