G
GeeRay
Hi all,
I have this problem: I need to implement a class hierarchy where the
main class has a template method that will be inherited by the subclass.
Something like:
class SuperClass
{
public:
template<typename T>
virtual void foo(const T& t) const = 0;
}
class SubClass: public SuperClass
{
public:
template<typename T>
virtual void foo(const T& t) const { cout << t << endl;}
}
Considering I know why it is not possible to make a template virtual, is
there an alternative pattern to solve this kind of problems.
Thanks in advance
I have this problem: I need to implement a class hierarchy where the
main class has a template method that will be inherited by the subclass.
Something like:
class SuperClass
{
public:
template<typename T>
virtual void foo(const T& t) const = 0;
}
class SubClass: public SuperClass
{
public:
template<typename T>
virtual void foo(const T& t) const { cout << t << endl;}
}
Considering I know why it is not possible to make a template virtual, is
there an alternative pattern to solve this kind of problems.
Thanks in advance