I want to declare an array of interfaces and further get a pointer to the list of interfaces Interface*
. But compiler (GCC
) prints error error: invalid abstract 'type Interface' for 'array'
. Code:
class Interface {
public:
virtual ~Interface() = default;
virtual void Method() = 0;
};
class Implementation : public Interface {
public:
void Method() override {
// ...
}
};
class ImplementationNumberTwo : public Interface {
public:
void Method() override {
// ...
}
};
// there is an error
static const Interface array[] = {
Implementation(),
ImplementationNumberTwo(),
Implementation()
};
How can I solve it?