If you have many methods that have similar signatures, only changing in type, the template method is the way to go:
struct Example { void load_from(std::istream&); void load_from(Database_Table&); void load_from(Some_Device&); };
The template method allows some extension:
struct Example_Template_Method { template <class Input_Source> void load_from(Input_Source&); };
The key point here is that template allows you to use a method, function or algorithm to work with various types of objects without changing the algorithm. This can also apply to interfaces.
source share