Is it possible to recreate such Java code in C ++ :
class Clazz { public void method(type arg) { } } interface Method { public void im(type arg); } public void run( Method m) { m.im(actualArg); } Clazz obj1 = new Clazz (); Clazz obj2 = new Clazz (); // передать obj1.method run(new Method() { public void im(type arg) { obj1.method(arg); } ); // передать obj2.method run(new Method() { public void im(type arg) { obj2.method(arg); } ); I mean that the function is passed as an argument , but also to declare it directly in the argument , without creating it separately and passing the reference to it as an argument. I am interested in whether there is such an opportunity in C ++ (in Java ), if not, I will pass the function as a link. Or maybe there is a better solution? I would be grateful for the advice and guidance.