funkcja przyjmująca interfejs

0

Hej mam taki problem. mam klasę abstrakcyjną Interfejs i klasa KlasaKtoraImplInterfejs dziedziczy po tym Interfejsie i implementuje metode toString.
no i jest taka funkcja przyjmującą ten interfejs:

void test(vector<Interfejs> &ob) {
	vector<Interfejs>::iterator it = ob.begin();
	for(it; it != ob.end(); ++it) {
		cout << (*it).toString() << endl;
	}
}

int main(void) {
	vector<KlasaKtoraImplInterfejs> obiekty;
	test(obiekty);
	return 0;
}

Eclipse podpowiada mi, że invalid initialization of reference of type ‘std::vector<Interfejs>&’ from expression of type ‘std::vector<KlasaKtoraImplInterfejs>’.
Jak z takimi rzeczami walczyć? dodam, że bez vectora z samym przyjmowaniem test(Interfejs &ob) a potem test(obiekt) działa okey.

3

Nie możesz mieć tablicy obiektów abstrakcyjnych.
Co najwyżej: vector<Interfejs*> &ob

1 użytkowników online, w tym zalogowanych: 0, gości: 1