I'm trying to make an interface an abstract class which would be implemented by derivated childs. One of methods in that class has to be variadic (children get one ore more QSharedPointer<QObject>
depending on implementation)
The problem is that:
templated methods cannot be virtual
I cannot make a variadic method taking
QSharedPointer<QObject>... args
arguments because oferror: expansion pattern ‘QSharedPointer<QObject>’ contains no argument packs.
Less words, more code:
class BaseClass {
public:
virtual void foo(QSharedPointer<QObject>... args) = 0;
}
class ChildClassA : public BaseClass {
public:
void foo(QSharedPointer<QObject> arg1);
}
class ChildClassB : public BaseClass {
public:
void foo(QSharedPointer<QObject> arg1, QSharedPointer<QObject> arg2);
}
I would like to use above classes to things like that:
template <class T = BaseClass>
class Controller<T>{
void callFoo(QSharedPointer<QObject>... args){
T* = new T();
T->foo(args);
}
}
As you can see the BaseClass is only to say: use one of my children as generic type.
How do I make such things work? Is it even possible in C++?