#include #include #include #include template class Vector2: public std::vector > { template friend Class &FBB::ForEach(Iterator begin, Iterator end, Class *object, void (Class::*member)(Data &)); public: void process() { FBB::ForEach(begin(), end(), this, &Vector2::rows); } private: void rows(std::vector &row) { FBB::ForEach(row.begin(), row.end(), this, &Vector2::columns); std::cout << '\n'; } void columns(Type &str) { std::cout << str << " "; } }; using namespace std; int main() { Vector2 c; c.push_back(vector(3, "Hello")); c.push_back(vector(2, "World")); c.process(); }