Can I create anonymous classes in C++ and capture the outside variables like in Java?
There is no way to automatically capture those variables, but you can use an alternative approach. This is if you want to capture by reference: int main() { int y = 100; // mark y as final if possible class IB : public IA { public: IB(int& y) : _y(y) {} int f(int x) { … Read more