How to implement in the following code the abstract base class in a generic case. The code is simplified from a library I am working on. So an explicit implementation for int and double is not an option.
template <typename T>
struct Foo
{
virtual void send(T t) = 0;
};
template <typename...T>
struct Bar : Foo<T>...
{
void send(T t) override { // does not compile because
// abstract method not implemented
}
};
int main() {
// example usage
Bar<int, double> b;
b.send(1);
b.send(2.3);
}
Many thanks in advance.
Edit: Added virtual to abstract method.
Foo2<T>...
andFoo2<T...>
(dots outside bracket vs. inside bracket) – Attention