I'm making a base class for my container classes to derive from so I can maintain a consistent interface. It currently looks something like this:
template <typename Datatype>
class BaseClass
{
public:
virtual Datatype Foo() = 0;
virtual Datatype Bar() = 0;
};
template <typename Datatype>
class DerivedClass: public BaseClass<Datatype>
{
public:
virtual Datatype Foo()
{
}
virtual Datatype Bar()
{
}
};
However, with some of my derived classes, Foo()
and Bar()
may need to have different return types from each other. Without having a template parameter for each different return type in the base class, how can I give the derived classes some room for changing this sort of thing?
EDIT:
The types the derived classes use are potentially completely different and invariant. Really, the derived classes aren't guaranteed to have any sort of common ground other than the method names.