Passing around a nested functor (C++)
c++, functor
Solution
No, currently local types aren't allowed to go into templates (otherwise you could've used boost or std::tr1::function). However, you could maybe do it OOP, where Foo inherits something (that has a virtual opeator() func that your foo implemen ts) and you pass a ptr to Foo around instead.
Problem
Is there a way to pass foo_ around outside of main? I saw something about Boost in another question regarding functors. That looks like it may work. Here's the answer mentioning Boost in that question. If I can, I would like to avoid Boost. ``` #include <iostream> int main() { class foo { public: void operator()() { std::cout << "Hello" << std::endl; } }; foo foo_; foo_(); return 0; } ```