I have a class Foo
that provides some sort of functionality. In order to maintain modularity, Foo
is to be an interface (That is, a C++ class with only abstract methods), and an implementation of Foo can choose how exactly to implement the functionality. However, my interface includes a template method. That is,
class Foo
{
public:
template<class T>
void functionality(const T&);
};
It is impossible in C++
to have template methods virtual
. Is there any technique that can achieve a similar result (Modularity and Polymorphism) with template methods?