Aby zaprezentować mój problem, wymyśliłem głupi przykład:
class a
{
public:
int zwrocTrzy()
{
return 3;
}
};
class b
{
public:
virtual int zwrocTrzy() = 0;
int dodajDwa()
{
return zwrocTrzy() + 2;
}
};
class c : public a, public b
{
public:
void cos()
{
dodajDwa();
}
};
int main()
{
c klasa;
}
Błąd który dostaje:
|In function 'int main()':|
error: cannot declare variable 'klasa' to be of abstract type 'c'|
because the following virtual functions are pure within 'c':|
virtual int b::zwrocTrzy()|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Rozwiazanie jakie znalazlem to dodanie do klasy c nast. funkcji:
int zwrocTrzy()
{
return zwrocTrzy();
}
Wszystko działa, tylko wydaje mi się dodanie takiej funkcji bez sensu. Czy nie da sie tego zrobić normalnie? czyli tak aby klasa b wiedziala, ze funkcji zwroc trzy znajduje sie w klasie a którą dziedziczy c?