I'd like to define an abstract base class and then pass an array of that type (obviously full of instances of a derived class) as a function parameter, but the compiler is yelling at me. Any ideas?
For example ("Testable" is abstract, "Vecteur" is concrete):
void Testeur::commencerTest(Testable testables[], int nTestables, string titre) {
cout << "\n" << titre << "\n";
for (int i=0; i < nTestables; i++) {
testables[i].afficher();
}
}
// in main function:
Vecteur v1 = Vecteur(1,2,3);
Vecteur v2 = Vecteur(4,5,6);
Vecteur vecteurs[] = { v1, v2 };
int nVecteurs = 2;
this->commencerTest(vecteurs, nVecteurs, "Some text");
The compiler says invalid abstract type ‘std::Testable’ for ‘testables’
at the first line of the above code.
How can I pass an abstract-typed array as a function param?