#include #include class Item; typedef std::function Action; class Item { public: explicit Item(int y) : y_(y) {} void do_action(int x) { action_(x); } Action action_; int y_; }; int main() { Item it1(3); Action a = [&it1](int x){ std::cout << "Wert x: " << x << " Wert y: " << it1.y_ << "\n"; }; it1.action_ = a; it1.do_action(5); }