I have a main class:
class Sportist{
private:
string ime;
int godina_na_ragjanje;
int godisna_zarabotuvacka_EUR;
public:
Sportist(string i, int g_n_r, int g_z_EUR){
ime = i;
godina_na_ragjanje = g_n_r;
godisna_zarabotuvacka_EUR = g_z_EUR;
}
};
And now I have a new class like this:
class Fudbaler:public Sportist{
private:
int broj_na_odigrani_natprevari;
int danocna_stapka;
public:
Fudbaler(string ime, int godina, int zarabotuvacka, int b, int d){
:Sportist(ime, godina, zarabotuvacka)
broj_na_odigrani_natprevari = b;
danocna_stapka = d;
}
float danok(){
return godisna_zarabotuvacka_EUR * danocna_stapka;
}
friend ostream& operator<<(ostream &os, Fudbaler F){
return os << "Ime: " << ime << endl
<< "Godina na raganje: " << godina_na_ragjanje << endl
<< "Godisna zarabotuvacka(EUR): " << godisna_zarabotuvacka_EUR << endl
<< "Danok sto treba da plati: " << danok();
}
};
I want to call the constructor from the first class in the second class, but I get errors that I haven't provided arguments which I do.. and also, I want to know how to access the private elements from the first class in the second, because it's taken as 'public', so how can I use them in my functions, like danok().
Errors while calling the constructor:
no matching function for call to 'Sportist::Sportist()'
candidates are:
Sportist::Sportist(std::string, int, int)
candidate expects 3 arguments, 0 provided
Error while calling variables using public method:
'int Sportist::godisna_zarabotuvacka_EUR' is private