#include <iostream>
#include <functional>

struct PrintHello
{
    void operator () ()
    {
        std::cout << "Hello";
    }
};

struct PrintWorld
{
    void operator () ()
    {
        std::cout << "World";
    }
};

template<typename Func>
class FooBar
{
public:
    FooBar() 
    {
    }
    
    FooBar(Func _func) : func(_func) 
    {
    }
    
    void print()
    {
        func();
    }

private:
    Func func;
};

void freeFunction()
{
    std::cout << "I'm free";
}

int main()
{
    FooBar<PrintHello> hello;
    FooBar<PrintWorld> world;
    FooBar<std::function<void()>> free_func(freeFunction);
    hello.print();
    std::cout << std::endl;
    world.print();
    std::cout << std::endl;
    free_func.print();
    std::cout << std::endl;
    return 0;
}
