I want to write a generic interface. I need a list of different objects in a std::vector. Each of this objects has a other type but the same interface.
For example:
struct Base
{
std::string name;
virtual void doWork(???, ???);
virtual void print(???,???);
};
struct ObjA : Base
{
void doWork(???,???) override
{
std::cout << "Hello\n";
};
void print(???,???) override
{
std::cout << "Hey\n";
};
}
struct ObjB : Base
{
void doWork(???,???) override { std::cout << "Hello\n"; };
void print(???,??? ) override { std::cout << "Hey\n"; };
}
But i don't know the type of ???,???. Since it is not possible to use virtual in combination with template's I'm searching for an elegant way.
Is it possible to solve this at compile time ?