#include using namespace std; template< typename T > void foo( T fun ) { fun(); } void bar() { cout << "hello from bar" << endl; } struct functor { void operator()() { cout << "hello from functor" << endl; } }; main() { foo(bar); // pass pointer to function foo(functor()); // pass functor instance }