How to simplify the adapter scheme?
问题 To make it clear, I post the code of "how to use" first: AB.h: #include <vector> #include <list> // execpt they both have children, A & B share nothing in common, // even children use different containers struct A { int num; std::vector<A> children; }; struct B { std::string s; float n; std::list<B> children; }; main.cpp: #include "Node.h" // handle A & B with the common interface Node // do not use template, since in practice, print() may be a large library void print(Node& n) { printf("%s\n